How to query an array

Source: Internet
Author: User
ID Hot
1 1
2 9,10,11
3 30
4 19,20,30
5 1,30
6 11
8 10,20,30
9 1,9,20

How do I find out if hot contains 1 of the data?

Final effect:
ID Hot
1 1
5 1,30
9 1,9,20


Reply to discussion (solution)

SELECT * from Tbl_name where Find_in_set (' 1 ', hot)

Thank you very much!

SELECT * from Tbl_name where Find_in_set (' 1 ', hot)


Need to write your own Find_in_set function!
Returns 0 rows after execution

Aren't you mysql?


SELECT * from Tbl_name where Find_in_set (' 1 ', hot)


Need to write your own Find_in_set function!
Returns 0 rows after execution



Find_in_set don't need yourself, I??? Yes, it's OK.




Line returns 0, you can see if there are??。 in the table



SELECT * from Tbl_name where Find_in_set (' 1 ', hot)


Need to write your own Find_in_set function!
Returns 0 rows after execution



Find_in_set don't need yourself, I??? Yes, it's OK.




Line returns 0, you can see if there are??。 in the table


What type of my data is in the wrong hot field! can use comma interval




SELECT * from Tbl_name where Find_in_set (' 1 ', hot)


Need to write your own Find_in_set function!
Returns 0 rows after execution



Find_in_set don't need yourself, I??? Yes, it's OK.




Line returns 0, you can see if there are??。 in the table


What type of my data is in the wrong hot field! can use comma interval


I'm using a varchar.

CREATE TABLE ' hot ' (' id ' int (ten) unsigned NOT NULL auto_increment, ' hot ' varchar ($) NOT NULL, PRIMARY KEY  (' id ')) E Ngine=myisam auto_increment=1 DEFAULT charset=latin1
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.