This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |
docs:mysql:select [2007/03/23 11:42] – billh | docs:mysql:select [2008/08/03 00:25] (current) – external edit 127.0.0.1 |
---|
| ====== SELECT ====== |
| ===== Joins ===== |
| * complex example: we want all records from table "parcels," and only corresponding fields from table "owners" where the owner_id matches, and we want to replace all column names that have spaces with underscores: |
| * select parcels.id, parcels.area, parcels.book, parcels.map, parcels.parcel, parcels.owner_id, owners.owner, owners.address, owners.city, owners.state, owners.zip, owners.phone, owners.phone_verified, owners.comments, parcels.`alternate owner id` as alternate_owner_id, parcels.acres, parcels.`recorder number` as recorder_number, parcels.`purchase price` as purchase_price, parcels.`purchase date`as purchase_date, parcels.`in house parcel id` as in_house_parcel_id, parcels.`tax status` as tax_status, parcels.comment, parcels.`shared assessor parcels`as shared_assessor_parcels from owners right join parcels on parcels.owner_id=owners.owner_id order by parcels.area, parcels.`in house parcel id` asc; |