I am using vb.net and Access 2010 as the database (.accdb)
This works with MySQL:
SELECT user_id, username, first_name, middle_name, last_name,
CASE is_enable WHEN 1 THEN 'Yes' ELSE 'No' END
FROM tbl_user_accounts ORDER BY user_id
But when passed the same query to Access, I get the following error:
Unrecognized keyword WHEN.
So I assume that the CASE Statement is different in access, or does access has that function at all?
P.S.
is_enable is boolean
You can also copy a query from one Access database to another. Open the "target" database in Access. Start a new "instance" of Access by clicking the Access icon on the Windows Start menu or from a shortcut. Select the query in the Navigation Pane in the first database and drag it to the other Access window.
A find duplicates query allows you to search for and identify duplicate records within a table or tables. A duplicate record is a record that refers to the same thing or person as another record.
If a field with a one-to-many relationship is in your filters, output, or sort, the record will appear multiple times-- once for each time the record meets the criteria. This allows you to check your query to ensure you get the expected results.
Figured it out:
Access 2010 does not have the CASE function, we use SWITCH instead.
SELECT user_id, username, first_name, middle_name, last_name, SWITCH(is_enable=True,'Yes',is_enable=False,'No')
FROM tbl_user_accounts ORDER BY user_id
Thanks to chuff and JW.
Alternatively, you can use IIF
IIF(is_enable = 1 , 'YES', 'NO')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With