Forum Moderators: coopster
I'm fairly new to php. I am trying to pull information from mysql. I've got it working perfectly, but I've run into trouble while trying to pull more than one set of values from a column in mysql.
ex.
$sql_count=" SELECT * FROM `demo8` where `Residential Styles`!='1)DET' and `Zip Code`='92008' ";
I would like to have it select 3 more Zip Code values being 92009, 92010, 92011
I'm sure it's simple, but I'm drawing a blank.
Thanks in advance!
$sql_count="select * from demo8 where `Residential Styles`!='1)DET' and `Zip Code` in (90028,90029,90030)";
You should probably have zip as a numeric format, but might not be able to if you're storing zip +4 (90030-1234).
If zip code is not one of the numeric formats, this will still work. I just tested it and surprised myself, the above query also returned the entry 90030-1234. I didn't think it would. :-)
Doesn't work for this though:
$sql_count="select * from demo8 where `Residential Styles`!='1)DET' and `Zip Code` in (90028,1234)";
Just returns the 90028 one.
Something to note, before you go . . .
$sql_count="select * from . . . .
If you're not using anything from this query and just as a count, this is a pretty high overhead, you're selecting all fields. Do
$sql_count="select count(*) from . . .
and this query will return a single-member array, the total row count.
$total = $row[0];