开发者

Beginner - Query a value in a column that's labeled as text

开发者 https://www.devze.com 2023-03-28 15:01 出处:网络
I have a database with one column which is labeled as text. I want to query just a single value from that text column. However, when I write the code in SQLyog, text turns into TEXT, which is apparent

I have a database with one column which is labeled as text. I want to query just a single value from that text column. However, when I write the code in SQLyog, text turns into TEXT, which is apparently related to character types in mysql. I just want to know how I can query the table for a value that is in a column labeled text.

开发者_如何学编程
SELECT id, keyword_netword_id, TEXT, match_type, create_date FROM keywords WHERE TEXT LIKE '%medicare supplemental insurance%';

I'm not typing in text as uppercase, it's just that SQLyog automatically turns into upper case.


simple:

SELECT `id`, `keyword_netword_id`, `text`, `match_type`, `create_date` FROM `keywords` WHERE `text` LIKE '%medicare supplemental insurance%';


I get the impression that you'd be better suited with a set typed column rather than text.

http://dev.mysql.com/doc/refman/5.0/en/set.html

EDIT: Unless, you're just asking how to get the whole column... In that case, TEXT is a reserved word in MySQL, you can put back ticks around column names if they have spaces or reserved words:

SELECT id, keyword_netword_id, `text`, match_type, create_date FROM keywords WHERE `text` LIKE '%medicare supplemental insurance%';
0

精彩评论

暂无评论...
验证码 换一张
取 消