第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用不同的值兩次連接同一個表

使用不同的值兩次連接同一個表

PHP
吃雞游戲 2022-12-23 13:12:29
我正在嘗試使用 ID 將“transfers.pickup_areas_group_id”和“transfers.drop_areas_group_id”的值替換為表“areas_group”中的值我正在使用這個查詢:SELECT transfers.id AS transfer_id, transfers.name AS transfer_name,  transfers.pickup_areas_group_id AS transfer_pickup_areas_group_id,transfers.drop_areas_group_id AS transfer_drop_areas_group_id, transfers_pricing.vehicle_id AS vehicle_id, transfers_pricing.date_start AS date_start, transfers_pricing.date_end AS date_end, transfers_pricing.price AS price FROM transfersINNER JOIN transfers_pricing ON transfers_pricing.transfer_id = transfers.id我嘗試了一個額外的 INNER JOIN 來替換第一個值“transfers.pickup_areas_group_id”,但我找不到替換第二個值“transfers.drop_areas_group_id”的方法我試過這個查詢:SELECT transfers.id AS transfer_id, transfers.name AS transfer_name,  transfers.pickup_areas_group_id AS transfer_pickup_areas_group_id,areas_group.area_id AS pickup_area_ids,transfers.drop_areas_group_id AS transfer_drop_areas_group_id, transfers_pricing.vehicle_id AS vehicle_id, transfers_pricing.date_start AS date_start, transfers_pricing.date_end AS date_end, transfers_pricing.price AS price FROM transfersINNER JOIN transfers_pricing ON transfers_pricing.transfer_id = transfers.idINNER JOIN areas_group ON areas_group.id = transfers.pickup_areas_group_id謝謝,
查看完整描述

1 回答

?
PIPIONE

TA貢獻1829條經(jīng)驗 獲得超9個贊

基本上,您需要另一個加入areas_group;要消除對同一個表的兩個引用的歧義,您需要使用表別名。


實際上,對在查詢中起作用的所有表使用表別名是一個很好的做法:這使得查詢更易于讀寫。


SELECT 

    t.id AS transfer_id, 

    t.name AS transfer_name,  

    t.pickup_areas_group_id AS transfer_pickup_areas_group_id,

    ag1.area_id AS pickup_area_ids,

    t.drop_areas_group_id AS transfer_drop_areas_group_id, 

    ag2.area_id AS drop_area_ids

    tp.vehicle_id AS vehicle_id, 

    tp.date_start AS date_start, 

    tp.date_end AS date_end, 

    tp.price AS price 

FROM transfers t

INNER JOIN transfers_pricing tp ON tp.transfer_id = t.id

INNER JOIN areas_group ag1 ON ag1.id = t.pickup_areas_group_id

INNER JOIN areas_group ag2 ON ag2.id = t.drop_areas_group_id


查看完整回答
反對 回復 2022-12-23
  • 1 回答
  • 0 關注
  • 101 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號