我的SQL查询从数据库中返回某些数据 [英] My sql query to return certain data from data base
问题描述
大家好,
首先感谢您的帮助.
我有一个问题要问.
我有一个包含5列的数据表.
公司--------用户:---------描述-------组-------共享
companyA ------- userA -------这是gA ------- A -------------否
companyB ------- userB -------这是gB ------- B -------------是
我的查询看起来像这样
Hi guys,
First of all thank you for your help.
I have a question to ask.
I have a data table with 5 columns in it.
company-------- user:--------- description------- group ------- shared
companyA------- userA ------- This is gA ------- A ------------- No
companyB------- userB ------- This is gB ------- B ------------- yes
My query looks like this
select * FROM t_groups WHERE User_Name='userA' and Company_Name='CompanyA'
但是我也想从共享的其他用户返回组.
因此,我想返回上述查询组,还要返回已共享的其他用户的组.
But i also want to return the groups from other users which are shared.
So i want to return the above queries groups but also the groups from other users that have been shared.
推荐答案
只需更改您的WHERE原因:
Just change your WHERE Cause:
select * FROM t_groups WHERE (User_Name='userA' and Company_Name='CompanyA') OR shared
这篇关于我的SQL查询从数据库中返回某些数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!