数据库常用操作

时间:2022-01-10 05:49:05

多张表之间的关联

select * from vas_user, vas_user_order where vas_user.userid=vas_user_order.userid

and vas_user.accountidentity like ykt%

and vas_user_order.ordertype=1

and vas_user_order.status=0

也可用代替符

select * from vas_user vu, vas_user_order vuo where vu.userid=vuo.userid

and vu.accountidentity like ykt%

and vuo.ordertype=1

and vuo.status=0

like的用法

语法

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern

样例

从 "Persons" 表中选取居住在以 "N" 开始的城市里的人

SELECT * FROM Persons
WHERE City LIKE N%

从 "Persons" 表中选取居住在以 "g" 结尾的城市里的人

SELECT * FROM Persons
WHERE City LIKE %g

从 "Persons" 表中选取居住在包含 "lon" 的城市里的人

SELECT * FROM Persons
WHERE City LIKE %lon%

从 "Persons" 表中选取居住在不包含 "lon" 的城市里的人

SELECT * FROM Persons
WHERE City NOT LIKE %lon%

 

相关:

https://www.w3school.com.cn/sql/sql_like.asp