mysql实现跨库多表查询

card和ec_products是一个数据库(card)的两张表,
card_kind是另一个数据库(card_kind)的表
在card库中查询语句如下:

		SELECT 
		   	card.id,
			card.card_num AS cardNum,
			ec_products.name,
			card_kind.card_kind.cardKindType,
			card_kind.card_kind.amount
		FROM
			card 
		LEFT JOIN
			ec_products
			ON 
			card.id = ec_products.card_id
		LEFT JOIN 
		    card_kind.card_kind 
		    ON 
		    ec_products.card_kind_id=card_kind.card_kind.id	

关键句:

		LEFT JOIN 
		    card_kind.card_kind 
		    ON 
		    ec_products.card_kind_id=card_kind.card_kind.id	

你可能感兴趣的:(MYSQL)