简体   繁体   English

如何从mysql表中检索没有默认值的值

[英]How to retrieve the values from the mysql table which are not having default value

I want to get the values in the mysql table which are not default values. 我想获取mysql表中不是默认值的值。 is there any way to use only sql query without using php? 有什么办法可以只使用sql查询而不使用php?

Use DEFAULT(col_name) . 使用DEFAULT(col_name)

eg 例如

SELECT *
FROM table
WHERE col1 != DEFAULT(col1)

If you want all rows where at least one column is not the default use OR : 如果希望所有行中至少有一列不是默认值,请使用OR

SELECT *
FROM table
WHERE col1 != DEFAULT(col1)
OR   col2 != DEFAULT(col2) # etc etc...

Or if you want all rows where all the columns are not the default use AND . 或者,如果您希望所有行都不是默认列的所有行,请使用AND

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM