Home > Blockchain >  SQL - Find specific value in a specific table
SQL - Find specific value in a specific table

Time:05-05

Say I have a table called "Team" with the following columns:

ID, MemberName ,ManagerName,Title

And I would like to retrieve all rows where a value "John" exists.

Assume "John" exists in a row for the MemberName column, and that "John" would exist in another row under the "ManagerName" column.

Please assume would have large number of columns. Greater than 50, and do would not know where the value would fall under statically.

CodePudding user response:

If you need an exact match for "John" you can use following query:

Select * 
From Team 
Where MemberName = 'John' or ManagerName = 'John'

If you need all rows where "John" could be a part of the string then you can use like:

Select * 
From Team 
Where MemberName like '%John%' or ManagerName like '%John%'

CodePudding user response:

Generally, you need to specify all the columns your are searching from in SQL.

SELECT * FROM Team WHERE 'John' IN (col1, col2, col3, ..., colN) ;

However that depends.

If you are using MySQL you can Search Table Data. From the MySQL Workbench right click the table , and choose Search Table Data.

If you are using PostgreSQL take a look at the following: https://stackoverflow.com/a/52715388/10436747

  •  Tags:  
  • sql
  • Related