<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1022950" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1022950</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141503</link>
    <description> &lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$where &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= array();&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$make&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[] = \&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;listing.Make_ID LIKE &#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$make&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;!=&#039;&#039;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;listing.`Year`&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$style&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;!=&#039;&#039;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;listing.style_ID LIKE &#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$style&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$price&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;!=&#039;&#039;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;listing.price LIKE &#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$price&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$milage&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;!=&#039;&#039;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;listing.milage LIKE &#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$milage&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$price&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;!=&#039;&#039;) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;listing.price LIKE &#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$price&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = implode(&#039; AND &#039;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;//mysql_query&lt;br /&gt;die(\&quot;&lt;br /&gt;SELECT listing.ID, listing.vehicle, listing.price, listing.Make_ID,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.style_ID, listing.`Year`, listing.milage, listing.image,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.color, listing.fuel, listing.enginesize, listing.transmission,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.aircon, listing.sunroof, listing.airbags, listing.powersteering,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listing.alloywheels, listing.featured, listing.other,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; body_style.ID AS sID, body_style.style, listing.reg&lt;br /&gt;FROM listing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LEFT JOIN body_style ON listing.style_ID=body_style.ID&lt;br /&gt;WHERE &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$where&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot;);&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;Take the output from this and try it in phpMyAdmin.&lt;/p&gt;
 </description>
     <pubDate>Tue, 25 Nov 2003 17:45:16 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1141503 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141490</link>
    <description> &lt;p&gt;ok so  first you cant use LIKE on int values and don&#039;t use &#039; around the values like Mark said the backticks around the field names are ok but the quotes around numerical values are not. also when using more then one table you have to name the table before the fields using a dot&lt;br /&gt;
so change this &lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote:&lt;br /&gt;
WHERE Make_ID LIKE &#039;$make&#039; AND `Year`&amp;lt;&#039;$year&#039; AND style_ID LIKE &#039;$style&#039; AND price&amp;lt;&#039;$price&#039; AND milage&amp;lt;&#039;$milage&#039; AND body_style.ID LIKE listing.style_ID&quot;);
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;to this&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;WHERE listing.Make_ID=$make AND listing.`Year`&amp;lt;$year AND listing.style_ID=$style AND listing.price&amp;lt;$price&lt;br /&gt; AND listing.milage&amp;lt;$milage AND body_style.ID=listing.style_ID&amp;quot;);&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;IMO you should change the price to decimal(7,2) so you can have more price precision but that a personnal opinion&lt;/p&gt;
 </description>
     <pubDate>Tue, 25 Nov 2003 13:49:11 +0000</pubDate>
 <dc:creator>druagord</dc:creator>
 <guid isPermaLink="false">comment 1141490 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Updated - Multiple condition select from MySQL</title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141482</link>
    <description> &lt;p&gt;This is my table structure for the two tables in the query:&lt;/p&gt;
&lt;p&gt;//**********************************&lt;br /&gt;
CREATE TABLE `listing` (&lt;br /&gt;
  `ID` int(11) NOT NULL auto_increment,&lt;br /&gt;
  `vehicle` varchar(32) default NULL,&lt;br /&gt;
  `price` int(11) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `Make_ID` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `style_ID` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `Year` int(9) default NULL,&lt;br /&gt;
  `reg` varchar(16) default NULL,&lt;br /&gt;
  `milage` int(11) default NULL,&lt;br /&gt;
  `image` varchar(150) default &#039;notavailable.jpg&#039;,&lt;br /&gt;
  `color` varchar(32) default NULL,&lt;br /&gt;
  `fuel` varchar(32) default NULL,&lt;br /&gt;
  `enginesize` varchar(32) default NULL,&lt;br /&gt;
  `transmission` varchar(32) default NULL,&lt;br /&gt;
  `aircon` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `sunroof` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `airbags` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `powersteering` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `alloywheels` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `featured` tinyint(4) NOT NULL default &#039;0&#039;,&lt;br /&gt;
  `other` text,&lt;br /&gt;
  PRIMARY KEY  (`ID`)&lt;br /&gt;
) TYPE=MyISAM;&lt;/p&gt;
&lt;p&gt;CREATE TABLE `body_style` (&lt;br /&gt;
  `ID` int(11) NOT NULL auto_increment,&lt;br /&gt;
  `style` char(32) default NULL,&lt;br /&gt;
  PRIMARY KEY  (`ID`)&lt;br /&gt;
) TYPE=MyISAM;&lt;/p&gt;
&lt;p&gt;//***************************************&lt;br /&gt;
And my query before I removed anything for troubleshooting is as follows:&lt;/p&gt;
&lt;p&gt;//***************************************&lt;br /&gt;
mysql_query(&quot;SELECT listing.ID, listing.vehicle, listing.price, listing.Make_ID, listing.style_ID, listing.`Year`, listing.milage, listing.image, listing.color, listing.fuel, listing.enginesize, listing.transmission, listing.aircon, listing.sunroof, listing.airbags, listing.powersteering, listing.alloywheels, listing.featured, listing.other, body_style.ID AS sID, body_style.style, listing.reg&lt;br /&gt;
FROM listing, body_style&lt;br /&gt;
WHERE Make_ID LIKE &#039;$make&#039; AND `Year`&amp;lt;&#039;$year&#039;  AND style_ID LIKE &#039;$style&#039;  AND price&amp;lt;&#039;$price&#039;  AND milage&amp;lt;&#039;$milage&#039; AND body_style.ID LIKE listing.style_ID&quot;);&lt;/p&gt;
&lt;p&gt;//***************************************&lt;/p&gt;
&lt;p&gt;My search form posts the following field:&lt;br /&gt;
$make - (ID number of a car make accoring to the &quot;car_make&quot; table)&lt;br /&gt;
$year - (Lates year of cars they want to view)&lt;br /&gt;
$style - (This is an integer value for the style ID which will call the style name from the &quot;body_style&quot; table)&lt;br /&gt;
$price - (Highest price of cars they want to view)&lt;br /&gt;
$milage - (Highest milage of cars they want to view)&lt;/p&gt;
&lt;p&gt;I use the LIKE condition so that I can use % for the default field just in case they want to view all cars will all milages and all prices etc.... For the ones that have &amp;lt; conditions, I use 9999999 as a default so that if they want to view all cars at any price, they would view all cars less than $9,999,999 etc.&lt;/p&gt;
&lt;p&gt;I hope this makes it easier for you to look at and make suggestions on how it can be done...&lt;br /&gt;
Thanks for the input so far.... &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;br /&gt;
Mizzy&lt;/p&gt;
 </description>
     <pubDate>Tue, 25 Nov 2003 11:01:41 +0000</pubDate>
 <dc:creator>mizzy</dc:creator>
 <guid isPermaLink="false">comment 1141482 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141466</link>
    <description> &lt;p&gt;Its better to ommit a field than use &quot;LIKE &#039;%&#039;&quot;.&lt;/p&gt;
&lt;p&gt;Year must be in backticks because Year is also a mysql function.  Enclosing it in backticks tells mysql you want the field.&lt;/p&gt;
&lt;p&gt;Do you get a mysql error?  Try having PHP print out the query being performed, then copy and paste it into a mysql client (phpMyAdmin or whatever) and run it.&lt;/p&gt;
 </description>
     <pubDate>Mon, 24 Nov 2003 17:41:23 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1141466 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141456</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;mizzy wrote:&lt;/strong&gt;&lt;br /&gt;
//***********************&lt;br /&gt;
mysql_query(&quot;SELECT listing.ID, listing.vehicle, listing.price, listing.Make_ID, listing.style_ID, listing.`Year`, listing.milage, listing.image, listing.color, listing.fuel, listing.enginesize, listing.transmission, listing.aircon, listing.sunroof, listing.airbags, listing.powersteering, listing.alloywheels, listing.featured, listing.other, body_style.ID AS sID, body_style.style, listing.reg&lt;br /&gt;
FROM listing&lt;br /&gt;
WHERE listing.Make_ID LIKE &#039;$make&#039; AND listing.`Year`&amp;lt;&#039;$year&#039;  AND listing.style_ID LIKE &#039;$style&#039;  AND listing.price&amp;lt;&#039;$price&#039;  AND listing.milage&amp;lt;&#039;$milage&#039;&quot;);&lt;br /&gt;
//***********************
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;What column type are listing.Make_ID ,listing.`Year`,listing.price AND  listing.milage&lt;br /&gt;
  - you cannot use &amp;lt; or &amp;gt; on varchar char or text fields if they are not text then don&#039;t use &#039;  around the values in the WHERE&lt;br /&gt;
  - Suzanne is right you have to put body style in the FROM&lt;br /&gt;
  - is listing.style_ID a text or varchar or char if not LIKE wont work&lt;/p&gt;
 </description>
     <pubDate>Mon, 24 Nov 2003 14:21:57 +0000</pubDate>
 <dc:creator>druagord</dc:creator>
 <guid isPermaLink="false">comment 1141456 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141422</link>
    <description> &lt;p&gt;If you&#039;re looking for body_style.ID and body_style.style, I think you need to add body_style to the FROM part. &lt;/p&gt;
&lt;p&gt;I will move the post as the folks who hang in the Server-Side Programming forum are fantastic with this. &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Do you have a sample URL? And code? .phps sort of thing (with passwords removed, of course) and some more information on your table structure may help.&lt;/p&gt;
 </description>
     <pubDate>Sun, 23 Nov 2003 22:33:20 +0000</pubDate>
 <dc:creator>Suzanne</dc:creator>
 <guid isPermaLink="false">comment 1141422 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141418</link>
    <description> &lt;p&gt;Moving it will be fine if that will help...&lt;br /&gt;
1. I am using 2 tables but just removed the deffinition of the other one for troubleshooting purposes.&lt;br /&gt;
I am only using the field from the &quot;body_style&quot; table for  one field which is not one of the search parameters so I removed it just in case it interfered with my output&lt;/p&gt;
&lt;p&gt;2. I am using PHP. I don&#039;t get any error messages... I parses fine... just that the output I am looking for is not there. &lt;/p&gt;
&lt;p&gt;Any help would be great&lt;br /&gt;
Thanks&lt;/p&gt;
 </description>
     <pubDate>Sun, 23 Nov 2003 19:40:06 +0000</pubDate>
 <dc:creator>mizzy</dc:creator>
 <guid isPermaLink="false">comment 1141418 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/multiple-condition-select-mysql#comment-1141415</link>
    <description> &lt;p&gt;why are you using the table name when you&#039;re only selecting from one table? oh, you&#039;re using two tables but not stating the other one...&lt;/p&gt;
&lt;p&gt;FROM listing, body_style&lt;/p&gt;
&lt;p&gt;Why is only Year back-ticked?&lt;/p&gt;
&lt;p&gt;listing.price should be less than or equal to $price, same with mileage.&lt;/p&gt;
&lt;p&gt;What errors are you getting and what language are you using? This post may have better response in the scripting forum, would you like me to move it?&lt;/p&gt;
 </description>
     <pubDate>Sun, 23 Nov 2003 18:17:40 +0000</pubDate>
 <dc:creator>Suzanne</dc:creator>
 <guid isPermaLink="false">comment 1141415 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
