title: 02-Cross-table-Query
date: 2023-11-17
status: DONE
tags:
- MySQL
- NOTE
- Lec2
author:
- AllenYGY
created: 2023-11-17T17:15
updated: 2024-03-21T21:44
publish: True
Cross-table-Query
The crossing of tables is the cartesian product of them.
Equivalent to querying from a (temporary) table A×B, the cartesian product of A and B.
temp=city x country
SELECT city FROM temp WHERE city.country_id=country.country_id AND country='China'
SELECT a1.city_id
FROM address AS a1, address AS a2
WHERE a1.city_id = a2.city_id AND
a1.address_id <> a2.address_id