question

Philosophaie avatar image
Philosophaie asked

Set an output if and only if two column data match

I need a SQL statement that will search for a entry in table "sessionregister" that looks at both columns "username" and "password" and gives the result in "ids" if and only if both the username and password in the same entry exists will ids be set. SELECT [ids] FROM [sessionregister] WHERE [username=@username],[password=&password];
select
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KenJ avatar image
KenJ answered
It looks like the logic is sound, but the syntax needs adjusted. use AND instead of ',' between WHERE conditions and don't enclose the various comparisons in square brackets [] SELECT [ids] FROM [sessionregister] WHERE username=@username AND password=@password
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.