PHP, MySQL query problem with syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

PHP, MySQL query problem with syntax

Post by me! »

it all works except the
WHERE asking_price >= '10.00'

Code: Select all

$sql = "SELECT * FROM equipment WHERE asking_price >= '10.00' AND sold_for = '0.00' AND sold_to = '' ORDER BY asking_price DESC LIMIT 3";
So what did I screw up?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP, MySQL query problem with syntax

Post by Christopher »

What type of field is asking_price? If it is not a CHAR/VARCHAR then it should be "asking_price >= 10.0"
(#10850)
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Re: PHP, MySQL query problem with syntax

Post by me! »

asking_price and sold_for are decimal(11,2)
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Re: PHP, MySQL query problem with syntax

Post by me! »

changed it to this but it still is not doing asking_price correct.

Code: Select all

$sql = "SELECT * FROM equipment WHERE asking_price >= 10.00 AND sold_for = 0.00 AND sold_to = '' ORDER BY asking_price DESC LIMIT 3";
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Re: PHP, MySQL query problem with syntax

Post by me! »

Ah! now I see my problem... "LIMIT 3" oops!
Post Reply