mysql多表聯結問題

時間 2022-06-03 11:50:11

1樓:匿名使用者

1全部select table1.id from table1 ,table2 where table1.id=table2.id

and table1.status='ok' and table2.title like '%遊戲%'

或select table1.id from table1 inner join table2 on table1.id=table2.id

where table1.status='ok' and table2.title like '%遊戲%'

你的錯誤在於,ok是字串,必須用引號引起來,標點符號混淆,其實該用英文的,以上這兩個都能正常執行 ,還有,你那個欄位叫什麼?status還是statu?你兩次寫的不一樣呢?

2樓:匿名使用者

select id, title from table1 inner join table2 on(table1.id=table2.id) where status='ok' and title like '%遊戲%'

還有一種簡單寫法

select id, title from table1 inner join table2 using(id) where status='ok' and title like '%遊戲%'

你的table1、id是中文的頓號,不是英文的點ok是字串,需要用引號引起來

其他的都很對

mysql多表查詢,相同欄位怎樣分別顯示

易冷 落 select a.name as name1,b.name as name2 from 表1 a left join 表2 b on a.uid b.id order by a.id desc 拓展回答 mysql是一個關係型資料庫管理系統,由瑞典mysql ab 公司開發,目前屬於 or...

mysql多表查詢合併到臨時表,怎麼再加一列並把各自的表名加上

insert into temp tableselect from select a id,name form aunion all select b id,name form b c 愛可生雲資料庫 我們仍使用 實驗 05 中的環境,略去準備資料的過程。我們仍然使用兩個會話,一個會話 run,用於...

MySQL資料庫多表查詢統計操作,求大神相助

可以通過count函式來實現。sqlone select from tablename1 where id 5 此語句查詢出來多條記錄,之後看做一個新的表。sqltwo select conut from select from tablename1 where id 5 as tablename2...