Search code examples
c#sqlsqlclient

How to retrieve data from the database without knowing the ID number?


I have a database with 3 values: id, credits, and name.

How can I get the credits of "some name" without knowing the id?

I only want to retrieve the users's credits in C#.


Solution

  • You can use an exact match with =:

    SELECT * FROM [MyTable] WHERE Name = 'some name'
    

    Or you could use LIKE with % wildcards to do a contains:

    SELECT * FROM [MyTable] WHERE Name LIKE '%some name%'