0

I want to find some word on my database column with SQL command

e.g.

-------------------
|       tb1       |
|-----------------|
| id              |
| name            |
-------------------

Records in name field

-> 1st Row "abc","aba","acc","bcc","aaa","bbb"
-> 2nd Row "abc","bcd","efc","aaa","sss","eee"
-> 3rd Row "acc","cdc","ass","qqq","sss","bbb"

how to find "acc" and "abc"

Tirapibal
  • 1
  • 1
  • `select * from tb1 where name='acc' or name='abc'`? – Professor Abronsius May 04 '17 at 06:29
  • how are these saved in column like `abc` or `"abc"` – Agam Banga May 04 '17 at 06:30
  • not yet "abc","aba","acc","bcc","aaa","bbb" same row – Tirapibal May 04 '17 at 06:31
  • Don't save CSV in a column http://stackoverflow.com/questions/41304945/best-type-of-indexing-when-there-is-like-clause/41305027#41305027 http://stackoverflow.com/questions/41215624/sql-table-with-list-entry-vs-sql-table-with-a-row-for-each-entry/41215681#41215681 Don't save CSV in a column Don't save CSV in a column – e4c5 May 04 '17 at 06:42

2 Answers2

0

If you want to select the rows from which the name field is equal to "acc" and "abc" then write

SELECT * FROM tb1 WHERE name LIKE '"acc"' OR name LIKE '"abc"';

Just in case if you want you can escape the double qoutes with \" not necessary though but this is how it would look like

SELECT * FROM tb1 WHERE name LIKE '\"acc\"' OR name LIKE '\"abc\"';

Or if you want just the name then write

SELECT name FROM tb1 WHERE name LIKE '\"acc\"' OR name LIKE '\"abc\"';
0

Use:

SELECT * FROM tb1 where name LIKE '%"abc"%';

Put string with double quotes "abc" inside '% .. %'.

informer
  • 821
  • 6
  • 18