Forum Moderators: coopster

Message Too Old, No Replies

Quick mySQL Statement

How do I have multiple 'and' statement in the SQL string

         

wonderbread

12:18 am on Jun 30, 2004 (gmt 0)

10+ Year Member



Hello everyone,

I'm sure this is a quick fix but I've been going nuts trying to figure it out and am not having much luck searching online. I am doing a simple SELECT sql statement trying to select based on 3 different values.

Code:

$sql = "SELECT * FROM table WHERE var1 = \"$var1\" and var2= \"$var2\" and var3 = \"var3\"";

I'm not sure how to include 3 'and' statements. Any help anyone could provide would be greatly appreciated.

Thanks in advance!

Nick LAdd

lorax

1:02 am on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$sql = "SELECT * FROM table WHERE var1 = '$var1' AND var2= '$var2' AND var3 = '$var3'";

You had it but just use single quotes for the variables you're testing against.