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!

sql and access question using IN statement

Status
Not open for further replies.

darrankavanagh

Programmer
Feb 20, 2005
1
IE
hi,
i am trying to pull all records from a table using the statement

Select * from messages where message_id in (5,6,7)
(is this correct syntax)
"message_id" is an AutoNumber field

i then update the "message_activated" fields to yes in my database that i get from the above sql.

The problem is that message_id 5 only gets updated.... and nothing happens to 6 and 7
anyone know why

Thanks
 
yes, that's the correct syntax, and if it's not updating all three then there's something wrong with your logic that constructs the update statement

but why do you retrieve them first?

why not just update the rows based on the same id numbers without selecting them first?

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)
 
In access you may try this:
UPDATE messages
SET message_activated = Yes
WHERE message_id In (5, 6, 7);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top