Jump to content

2 AND commands?


liamloveslearning

Recommended Posts

Hi all,

I need to query my database where x is y and where x is also z if this makes sense?

 

My query is something similiar to...  SELECT * FROM 'x' WHERE x=x AND model_pictures.theme=1  AND model_pictures.theme=3 only it isnt working, Is it possible to have somthing like..

 

AND model_pictures.theme=3 AND 1?

Link to comment
Share on other sites

model_pictures.theme=1  AND model_pictures.theme=3

 

A column can only have a single value at any time. ^^^ Using AND there won't match anything because the value cannot be both 1 and 3 at the same time. You need to use OR to form a union/set of rows that have the values 1 OR 3.

Link to comment
Share on other sites

My query is

SELECT model_login.id, model_login.username, model_pictures.id, model_pictures.user_id, model_pictures.user_picture, model_pictures.user_picture_date, model_pictures.user_pic_approval FROM model_pictures, model_login WHERE model_pictures.user_id=model_login.id  AND model_pictures.user_pic_approval=1  AND model_pictures.theme=1 OR model_pictures.theme=3

 

Does this seem valid ?

Link to comment
Share on other sites

hello

 

I recommend you to use in clause instead of several or clause

 

select * from phones where brand in ('sony ericsson','panasonic','lg')

 

works the same like

select * from phones where brand = 'sony ericsson' or brand='panasonic' or brand = 'lg'

 

see ya

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.