Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am doing a DAOdatabase programming in Visual C++ 6.0, wherein I want to give a query to check if a particular item is present in Table field or not. That is, I want to perform a set of functions only if the record is present in the table field otherwise not.
Can anyone please suggest how to implement it?

I think "select (count)from <tablename> where (condition)" can check if the item is present.But I did not get its correct implementation in VC++.
If i get the return value of count, i can use it in my program.

I even tried it with try and catch method, but i got some error.

Please help.

Timkee
Posted

The syntax should be "COUNT(*)", e.g.

SELECT COUNT(*)
FROM Customer
WHERE ID=459


Maybe you could take a look at the definition of the COUNT SQL syntax[^].
 
Share this answer
 
Don't know about DAO. For MySQL this would be optimal:
SELECT 1 FROM `table` WHERE `id` = '1' LIMIT 1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900