monkeytooth Posted October 24, 2008 Share Posted October 24, 2008 is it possible to have an AND in the same query as a WHERE? $dbconn = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or die("Error: " . mysql_error()); mysql_select_db($database) or die("Could not select database"); $mycrecs2z = " SELECT * FROM compy_jobs " . " WHERE jstatus = '95998' "; " AND jcounty = 'Hartford' "; " LIMIT 0, 10 "; $mycrecs2az = mysql_query($mycrecs2z) or die('Error, query failed<br>' . mysql_error()); mysql_close(); If so what am I doing wrong? The WHERE works fine, the AND not so much I have no Hartford in my database matching the WHERE.. any one able to help me out? Link to comment https://forums.phpfreaks.com/topic/129988-solved-php-mysql-where-and-possible/ Share on other sites More sharing options...
The Little Guy Posted October 24, 2008 Share Posted October 24, 2008 Try this: $mycrecs2z = " SELECT * FROM compy_jobs WHERE jstatus = '95998' AND jcounty = 'Hartford' LIMIT 0, 10 "; $mycrecs2az = mysql_query($mycrecs2z) or die('Error, query failed<br>' . mysql_error()); mysql_close(); Don't open and close you code so many times Link to comment https://forums.phpfreaks.com/topic/129988-solved-php-mysql-where-and-possible/#findComment-673884 Share on other sites More sharing options...
monkeytooth Posted October 24, 2008 Author Share Posted October 24, 2008 That helps lol, dont know why i didnt think of that myself, I usually dont break it down as badly as that but Im workin with someone elses code, orginal designer bailed on this project (i can see why, the clients a pain) and im picking it up.. so i didnt think anything of it.. good call.. One more question though, could I do that with a COUNT to? Gotta make an index based of the searches as this site has 1 to several thousand results pending on the keyword.. but the orginal designer thought it would be a good idea to have it all list in one shot rather then break it into pages of x per page Link to comment https://forums.phpfreaks.com/topic/129988-solved-php-mysql-where-and-possible/#findComment-673905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.