㈠ sql 新手。 求幾個簡單的查詢語句。
1.select * from A where A.year >2007 or (a.year = 2007 and a.month > 02) or (a.year = 2007 and
a.month = 02 and a.day > 12)
2.select * from B where not Exists (select UserID from A where A.UserID = B.UserID)
3.select * from B where Exists (select UserID from A where A.UserID = B.UserID)
4.select top 10 * from B where B.Sex = 'Male' order by B.Age desc
union all
select top 10 * from B where B.Sex = 'Female' order by B.Age desc
個人理解,僅供參考
㈡ 最簡單的SQL語句
select c_name, c_stu from class where c_stu>50 or c_stu<20
樓上這個可不對了。。c_stu between 50 and 20的意思是c_stu>=20 and c_stu<=50,正好和原意相反!
㈢ 關於sql查詢語句(簡單)
select top 1 * from RoomType 是返回一行 包括所有欄位
TypeID not in (select top 1 * from RoomType) 一個欄位是不可能和一整行比較的。
正確寫法如下:
select top 3 * from RoomType where TypeID not in (select top 1 typeid from RoomType)
㈣ 求一句簡單的SQL查詢語句
如果確保B中的B_ID無重復,可以用子查詢
select A_ID,A_B_ID,A_Name,(select B_Name from B where B_ID=A_B_ID) from A
如果B_ID可能會重復,又要查詢出所有A表的數據,那就用聯合查詢,左外連接
SELECT A_ID, A_B_ID, A_Name, B_Name
FROM A LEFT OUTER JOIN
B ON A_B_ID = B_ID
㈤ SQL簡單的查詢語句.
select *
from dbo.CeshiTable
where DateTime=2005 and Address like '%株%'
不要用等號,等號表示完全匹配,like表示模糊查詢
㈥ 一個簡單的sql查詢語句幫忙一下
你可以這樣
...select count(*) as cot from gs...
rs("cot")就是count(*)的值
㈦ SQL查詢語句,寫幾個簡單查詢語句
你說明白點,(1)select * from 員工表 where 員工車間號=(select 員工車間號 from 工廠表 where 工廠表車間號='3') and 性別=『男』(2)select count(*) from 員工表 where 員工車間號=(select 員工車間號 from 工廠表 where 工廠表車間號='2') and 性別=『女』(3)select * from 零件表 where 零件號=『002』(4)select 車間主任姓名 from 車間 where 車間號=(select 車間號 from 產品 wehre 產品號=『005』(5) select * from 零件表 where 零件價格<20
㈧ sql簡單查詢語句
1、首先打開資料庫,建立好表。
㈨ 求簡單的SQL查詢語句
兩個表裡面有相同欄位uid , select * 能用嗎?
你先的把問題拆開來看看
1.select * from Gqinfo where uid = session("uid")
2.select * from user where uid = session ("uid")
如果在2裡面有,1沒有,就可以 用 left join
select u.field1,u.field2,...g.field1... from user u left join gqinfo g on u.uid = g.uid
where u.uid = session("uid")
㈩ sql語句實現一個簡單的查詢
假設表的名字為t1:
select * from t1 where b in (select b from t1 group by b having count(b)>1)