求一段SQL语句,太绕了,小弟我自己绕不出来了
求一段SQL语句,太绕了,我自己绕不出来了。
表名:tables
以下为表内字段:
id(int)|value(varchar)|username(varchar)
以下为表内现有的记录:
1|AX,BX,CX,DX|名字1
2|AY,BY,CY|名字2
3|AZ,BZ,CZ,DZ,EZ,FZ|名字3
4|AX,BY,CZ,DZ|名字4
5|DZ,CY,BX,MZ|名字5
现在我需要的是通过获取到的值查询value字段
比如我现在获取到了"DZ,AZ,DX"这个值,然后我需要一个sql语句来做到根据获得的值来查询得到value这个字段里所有含有DZ和AZ和DX的所有记录,但同时如果只查询“A”这个值的时候却在以上记录中查询不到结果。
我自己绕了半天也没绕出来,谁帮我构造一下,或者帮我理一下思路。
万分感谢
------解决方案--------------------
FIND_IN_SET
------解决方案--------------------
`VALUE` like "%DZ%"
or
`VALUE` like "%AZ%"
or
。。。。
这样?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

1. The difference in matching content. LIKE requires that the entire data must be matched. With Like, all the contents of this field must meet the conditions; REGEXP only requires partial matching, and only one fragment needs to be satisfied. 2. Differences in matching positions: LIKE matches the entire column. If the matched text appears in the column value, LIKE will not find it and the corresponding row will not be returned (unless wildcards are used); REGEXP is within the column value. A match is performed. If the matched text appears in the column value, REGEXP will find it, the corresponding row will be returned, and REGEXP can match the entire column value (same effect as LIKE). 3. The SQL statement returns data that differs from LIKE matching: the SQL statement

During the use of MySQL, dates are generally stored in datetime, timestamp and other formats. However, sometimes due to special needs or historical reasons, the date is stored in varchar format. So how should we process the date data in varchar format? ? Use function: STR_TO_DATE(str,format) The STR_TO_DATE(str,format) function is the inverse function of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains date and time components, or if the word

The LIKE operator is used to search for a specified pattern in a column in the WHERE clause. Syntax: SELECTcolumn_name(s)FROMtable_nameWHEREcolumn_nameLIKEpatternpattern This is where the specified template is placed, and "%" is used here, also called the wildcard character %. If it is placed in front of the condition, it will search for data ending with...; for example: % If Li % is placed after the condition, then the data starting with... is searched; for example: Li %% exists before and after the condition, then the included data is searched; for example: % Li % Little knowledge point: ERROR1064 (42000):Youhaveane

The differences between char and varchar in mysql are: 1. CHAR is fixed length, while VARCHAR is variable length; 2. CHAR storage and retrieval efficiency is high, while VARCHAR storage and retrieval efficiency is not high; 3. CHAR takes up storage space, VARCHAR can save storage space.

Optimize the Like statement with Union 1) Sometimes, you may need to use the or operator for comparison in the query. When the or keyword is used too frequently in the where clause, it may cause the MySQL optimizer to mistakenly choose a full table scan to retrieve records. The union clause can make queries execute faster, especially when one of the queries has an optimized index and the other query also has an optimized index. For example, when there are indexes on first_name and last_name respectively, execute the following query statement: mysql>select*fromstudentswherefirst_namelike'A

First of all, it is not recommended to use the TEXT type, because using TEXT will seriously affect efficiency. The best way is to use VARCHAR and determine the maximum length of the field. We can first define a field rule_value in the table and set the length to 255, then enter the smallest json string: use MySQL's CHAR_LENGTH function to calculate the size of rule_value: SELECTid, rule_type, rule_value, CHAR_LENGTH(rule_value) as rule_value_length, rule_markFROMtest_tableWHEREr

图片消失如何解决先是图片文件上传$file=$_FILES['userfile']; if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'
