Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从表中选择所有图像。我的专栏是file_ext,包含jpg、jpeg、mp3、avi等扩展名。
我如何创建这样的 SQL 查询?:AND file_ext = 'jpg, jpeg'或选择所有扩展AND file_ext = '*'因为我不想写AND file_ext = 'jpg' AND file_ext = 'jpeg' ....
AND file_ext = 'jpg, jpeg'
AND file_ext = '*'
AND file_ext = 'jpg' AND file_ext = 'jpeg' ....
各位大佬是怎么解决这样的问题的?谢谢!
试试IN喜欢
IN
SELECT * FROM table WHERE mycondition AND file_ext IN ('jpg','jpeg','png',....)
并且 ALso 尽量避免mysql_*声明,因为整个ext/mysql PHP扩展提供了以前缀命名的所有函数mysql_*,从 开始正式弃用,并将在未来PHP v5.5.0被删除。
mysql_*
ext/mysql PHP
PHP v5.5.0
您可以更好地使用其他两个MySQL扩展:MySQLi和PDO_MySQL,其中任何一个都可以用来代替ext/mysql.
MySQL
MySQLi
PDO_MySQL
ext/mysql