mysql語句求解
1樓:網友
type是定義欄位型別的, 就像varchar是字元型一樣, enum說明這個欄位是列舉型別,後面括號裡面是這個列舉型別的值,也就是說這個欄位只可能有這三種值,乙個是home, 乙個是work,乙個是other
請問乙個mysql語句
2樓:網友
select * from sp where id_dp = 0 or id_dp in (select id_dp from dp)
id_dp和dp表中的id_dp最好都是建立了索引的。
3樓:
得到結果再與下面那句話,自然鏈結,「natural left outer join (select * fron sp where ip_dp=0)」
mysql新增唯一約束語句
4樓:雁子
當為欄位指定唯一約束後,那麼欄位的值必須是唯一的。這一點與主鍵相似!例如給stu表的sname欄位指定唯一約束:
create table tab_ab(
sid int primary key auto_increment,sname varchar(10) unique);
請問mysql語句怎麼寫?
5樓:校巨集盛
select
goods_name 產品名字,max(price) **,max(case rank_name when 'vip1' then (case when user_price is null then discount*price/100 else user_price end) end) vip1**,max(case rank_name when 'vip2' then (case when user_price is null then discount*price/100 else user_price end) end) vip2**,max(case rank_name when 'vip3' then (case when user_price is null then discount*price/100 else user_price end) end) vip3**。
from member_price mp
left join goods gd on =
left join user_rank ur on =
group by goods_name;
mysql不是很熟悉,所以寫了個標準sql語法的。我記得mysql中group by的select可以不用跟聚合函式的,所以lz大概可以把max()去掉,而mysql中好像有isnull,ifnull的函式,我不太瞭解,這裡用case語句替代了,lz可以自行替換。
6樓:等待著的緣分
你這個member_price 表示不是設計有問題,要想顯示 產品名字 ** vip1** vip2** vip3** 級應該設計為 price_id, goods_id, user_price ,vip1_price,vip2_price,vip3_price!
mysql語句問題
7樓:網友
@mysql_result($query, $row);
你怎麼寫3個引數?
伺服器認為你已經重寫了這個方法了。所以提示。
求一條SQL語句
樓上兩位的都有問題。應該是 select a.tid,tkh,tname,sum t2a sum t2b from table1 a,table2 bwhere a.tid b.tid and tkh 50 group by a.tid,tkh,tname select table1.tid,tkh...
求一條SQL語句
select from select from 表 where 列2 is null union select from 表 where 列2 is not null and rownum 100 case when select count from 表 where 列2 is null 100 ...
求一條SQL語句,有關聯合查詢的
試試看這樣行不行 select 表b 學號 表a 姓名 isnull sum case 表b 學科 when n 語文 then 表b 分數 end 0 as 語文 isnull sum case 表b 學科 when n 數學 then 表b 分數 end 0 as 數學 isnull sum c...