Jump to content

[SOLVED] PHP mySQL WHERE AND possible?


monkeytooth

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.