redbishop — 2014-02-01T02:45:05-05:00 — #1
please help me with a query. Do you think the following should work, or is it only possible with integers? I am trying to return those columns where one row has a field named beer, and one row has a field named wine. Do to the current setup, I'm unable to use the row ID. Or is this impossible?
The echoed-out query looks like this:
WHERE name = 'simon' && booz IN (beer,wine)
Thank you in advance!!
r937 — 2014-02-01T04:55:04-05:00 — #2
rows cannot possibly have differently named columns
but yes, you can use IN with strings, and even with column names
pro tip: use AND instead of &&
redbishop — 2014-02-01T05:07:03-05:00 — #3
thank you. For some reason I get the error:
mysql_num_rows() expects parameter 1 to be resource, boolean given.
Must the strings be quoted perhaps?
r937 — 2014-02-01T05:35:04-05:00 — #4
i don't do php but you get this because your query died before it executed and you're not testing for successful execution (don't ask me how to do that) before using mysql_num_rows()
if they're strings and not column names, yeah
redbishop — 2014-02-01T05:39:41-05:00 — #5
Okay thank you, perhaps that is the reason for the error.
Hope you have a good weekend.