Note that there are some explanatory texts on larger screens.

plurals
  1. USHelena
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. COOh, it's true that what I've written doesn't actually work... shame on me. How about storing the count in an integer variable beforehand: `SELECT $event_count = COUNT * FROM [` fill in appropriately - probably it would be the SELECT just after "cur_rec IN" `]` (having previously declared `$event_count` as an integer) and then testing whether it's zero or positive? I.e. `IF $event_count = 0 THEN ... ELSE ...`. I believe an IF statement itself shouldn't be causing an error whether it's inside a FOR loop or not (except when there's a syntactic error).
      singulars
    2. CODepending on the complexity of your database and also on the options available (I've never worked with Postgre) one of the suggestions might be to generate a random pair the way you're doing it (without all the conditions, just order all `media_id`'s randomly and take the top 2), save them into two variables and then check if this pair is already in the `battle_votes` table (in either order); if yes throw it away and generate a new pair. This is already some SQL programming however - not sure if you have the option of writing and running stored procedures.
      singulars
    3. COAre you re-inventing Facebook from scratch? ;) (might not make sense to those who haven't seen The Social Network or read much about the history of fb)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload