Pete Winter
asked on
Where id = xxx or xxx or xxx
How do I write the following...
See code below:
$query_rs_spares_also = "SELECT * FROM spares WHERE id = ".$row_rs_spares['also_pur chased1'];
I want to say where the id is equal to $row_rs_spares['also_purch ased1'] or $row_rs_spares['also_purch ased2'] or $row_rs_spares['also_purch ased3']
See code below:
$query_rs_spares_also = "SELECT * FROM spares WHERE id = ".$row_rs_spares['also_pur
I want to say where the id is equal to $row_rs_spares['also_purch
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$query_rs_spares_also = "SELECT * FROM spares WHERE id IN (".$row_rs_spares['also_pu rchased1'] .", ".$row_rs_spares['also_pur chased2']. ", ".$row_rs_spares['also_pur chased13]. ")";
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If the number of values is not defined you can do:
$query = "SELECT * FROM spares WHERE id IN(".implode(",",$row_rs_s pares).")" ;
$query = "SELECT * FROM spares WHERE id IN(".implode(",",$row_rs_s
ASKER
Thanks you all for your reply, but...
alain34 & leakim971 I get the following error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
ludofulop
I get a blank page.
Please can you check my code attached.
alain34 & leakim971 I get the following error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
ludofulop
I get a blank page.
Please can you check my code attached.
mysql_select_db($database_conn_tech8, $conn_tech8);
$query_rs_spares_also = "SELECT * FROM spares WHERE id IN(".$row_rs_spares['also_purchased1'].",".$row_rs_spares['also_purchased2'].",".$row_rs_spares['also_purchased3'].")";
$rs_spares_also = mysql_query($query_rs_spares_also, $conn_tech8) or die(mysql_error());
$row_rs_spares_also = mysql_fetch_assoc($rs_spares_also);
$totalRows_rs_spares_also = mysql_num_rows($rs_spares_also);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Leakim971 My error occurred when of the variables was null.
You're welcome! Thanks for the points!