Jump to content

help with where clause


MDanz

Recommended Posts

this isn't working out.  I want the first part of the if statement to get both results in mysql with adult=1 and 0.  i think i did it wrong.  Whats the correct way?

 

	
  if($adulton == 1) { 
$adult="adult=1 AND adult=0";
}
else {
$adult="adult=0";
}

 

WHERE keywords LIKE '$letter%' AND Amount>=1 AND $adult 

Link to comment
Share on other sites

Hi,

 

if($adulton == 1) { 
$adult="adult=1 AND adult=0";
}

 

Here, adult can be 1 and 0 at the same time. User OR connection.

 

if($adulton == 1) { 
$adult="adult=1 OR adult=0";
}

Link to comment
Share on other sites

thanks but now the first parts of the where clause are being ignored.  Do i have to use brackets around $adult to make it specific.?

 

SELECT DISTINCT keywords FROM Core WHERE keywords LIKE '$letter%' AND Amount>=1 AND $adult ORDER BY keywords DESC"

 

this is getting all rows from mysql where adult='0'.. it is ignoring the keywords LIKE '$letter%' AND Amount>=1

Link to comment
Share on other sites

thanks for help.  i have 1 row in mysql where adult=1. the rest are adult=0.

 

When i run the query i want to filter out the adult results.  For some reason the query isn't working.

 

when i turnoff the adult filter... it shows both adult=1 and adult=0 rows, when it should only show adult=0 rows.  It's a query problem.

 

any idea why?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.