PDA

View Full Version : Problem with WHERE in MySql PHP



sigepmest37
September 11th, 2006, 06:07 PM
It always seems like the easiest part of the code generates the biggest problems.

I am running a search query into a products table. I have all that down just fine. I then decided to also make it so that no products with a price of 0.00 are returned. This is what I came up with:



$query = "SELECT * FROM ds_products WHERE (pName LIKE '%shift%') || (pNum LIKE '%shift%') AND pSalesPrice!='0.00' ORDER BY 'pSalesPrice' ASC LIMIT 0, 12";


It isn't generating an error, but it IS returning products with the price of 0.00.

What am I doing wrong?

Thanks in advance for the help!

bwh2
September 11th, 2006, 06:13 PM
try:
$query = "SELECT *
FROM ds_products
WHERE (
pName LIKE '%shift%'
OR pNum LIKE '%shift%'
)
AND pSalesPrice != 0
ORDER BY pSalesPrice ASC LIMIT 0, 12";

raz
September 11th, 2006, 06:14 PM
Cant you just return all the results and add a simple if statement:



<?
if (pSalesPrice!='0.00') {
print;
}
else {
dont print;
}

sigepmest37
September 11th, 2006, 06:15 PM
try:
$query = "SELECT *
FROM ds_products
WHERE (
pName LIKE '%shift%'
OR pNum LIKE '%shift%'
)
AND pSalesPrice != 0
ORDER BY pSalesPrice ASC LIMIT 0, 12";

YOU ROCK!!

bwh2
September 11th, 2006, 06:25 PM
no problem.