用php將mysql的表查詢出來,該怎麼寫,用來考二級mysql的

時間 2022-06-10 03:40:05

1樓:滬漂峰哥

select * from b where b表字段 in (select a表字段 from a)

其中in可根據需要用其他如like等替代

2樓:

select * from b where id in (select id from a)

php中mysql一條sql語句查詢出所有符合條件的資料,該怎麼寫?

3樓:山水阿銳

您好,不知道你的a,b兩表有沒有關聯,假定沒有關聯select count(1)

from

(select id

from a

where id>5

union all

select id

from b

where id>5)

mysql裡面有學習成績單表,想通過php下拉列表的從資料庫把裡面的表顯示在頁面上 怎麼實現? 急用 !!!

4樓:泠泠殺手

這個的話建議用ajax實現!!如果你不會的話那就在後邊加乙個提交按鈕用get的方式實現

5樓:俠客視界

ajax非同步重新整理,你搜尋下相關的資料看看就明白了,呵呵

6樓:匿名使用者

這個你可以用ajax實現!

sql查詢,我用的php和mysql

7樓:匿名使用者

查詢本週記錄

select * from ht_invoice_information where weekofyear(create_date)=weekofyear(now());

#查詢上週記錄

select * from ht_invoice_information where create_date>=date_add(now(),interval -(8 + weekday(now())) day)

and create_date<=date_add(now(),interval -(1 + weekday(now())) day);

#或者select * from `ht_invoice_information` where weekofyear(create_date)=weekofyear(date_sub(now(),interval 1 week));

#查詢本月資料

select * from ht_invoice_information where month(create_date)=month(now()) and year(create_date)=year(now());

#查詢上月資料

select * from ht_invoice_information where create_date<=last_day(date_add(now(),interval -1 month))

and create_date>=date_format(concat(extract(year_month from date_add(now(),interval -1 month)),'01'),'%y-%m-%d');

#或者select * from `ht_invoice_information` where month(create_date)=month(date_sub(now(),interval 1 month))

and year(create_date)=year(now());

#查詢本季度資料

select * from `ht_invoice_information` where quarter(create_date)=quarter(now());

#查詢上季度資料

select * from `ht_invoice_information` where quarter(create_date)=quarter(date_sub(now(),interval 1 quarter));

#查詢本年資料

select * from `ht_invoice_information` where year(create_date)=year(now());

#查詢上年資料

select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year));

參考這個吧,很全了。

8樓:辰溪老土匪

select case when b like '專用' then'' when b not like '專用' then b end from 表

語法我沒測試 可能有問題

但是 程式設計在乎思路 結果其次

php如何把mysql資料庫表查詢出來的資料顯示在html頁面的**裡

php 如何根據乙個條件用mysql查詢最新的記錄 50

9樓:匿名使用者

select * from xx order by id desc;(根據id排序)或者select * from xx order by reg_time desc;(加個時間字段排序即可)

php 用哪個版本的MySQL好?

用整合環境吧,比較搭。以上,沒有任何區別。php用5.3,mysql用5.5用哪個版本最好 帝國cms php版本和mysql版本本身沒有依賴關係,也跟你將要搭載什麼 系統沒有依賴關係,我個人倒是建議php版本別那麼低,及以上就挺好的,我個人目前用的5.15。我個人的原則就是不用最新的,生怕不穩定 ...

mysql選擇表查詢的問題,當表A中存在記錄則輸出A表資料,否則輸出B表資料

select id name,other from select nvl a.id,b.id id nvl a.name,b.name name nvl a.other,b.other other from a full outer join b on a.name b.name where nam...

sql如何把查詢出來的多個表建立成臨時表

select into temp from select a,b,c from table1 union all select a,b,c from table2 1 sql server使用select into會自動生成臨時表,不需要事先建立。select into temp from syso...