Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Conditions/Actions in single query

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR

Hello!

Does anyone know if it is possible to have multiple conditions inside a single query?

Condition 1 is : UPDATE table SET mydata = "hello" WHERE condition LIKE 'yes'
Condition 2 is : UPDATE table SET mydata = "goodbye" WHERE condition LIKE 'no'

Having both in the same query is possible? Or do I have to connect to the database
as many times as there are conditions?

Thanks a lot for the help.
 
UPDATE table SET mydata = "hello" WHERE condition LIKE 'yes' or (condition LIKE 'no' and answer LIKE 'maybe')
 
Hello Gheist,

Thanks for the feedback. Unfortunately, what you wrote
won't do it.
If you look closely to my post, you'll notice that the
data to store in the db is different in each condition.

The query should write "hello" as mydata WHERE condition LIKE 'yes' but it should right "goodbye" WHERE condition is something else.

Thanks anyway.
 
UPDATE tablee
SET mydata = "hello" WHERE conditionn LIKE "yes",
SET mydata = "goodbye" WHERE conditionn LIKE "no",
SET condition ="wow" WHERE mydata like "me%";

etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top