MySQL IF... SELECT statement whilst retaining column headers
Fumbling in the dark with MySql but it isn't too bad. (I am a coding novice)
I have a massive database that I need to join to another database (in Arc
GIS). I originally did some code to get the joining database with headers
(necessary for the join) as that surprisingly didn't come as standard when
generating sub data sets with MySQL.
As it is still 3 million records I need to wittle the data down. I am
originally did this by querying whether it contained part of a grid square
reference (but no titles!). So now I'm trying to see if it contains an
image number (grid_image) whilst retaining the column headers. So IF it a
field contains a certain number SELECT ... INTO OUTFILE.
I'm struggling with the IF though, any help would be greatly appreciated :).
Laura
Code thus far:
WHERE geograph_db.image_numbers.column1 =
geograph_db.gridimage_geo.gridimage_id
SELECT 'gridimage_id','nateastings','natnorthings', 'view_direction'
UNION
SELECT gridimage_geo.gridimage_id, gridimage_geo.nateastings,
gridimage_geo.natnorthings, gridimage_geo.view_direction
INTO OUTFILE 'geo.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
FROM geograph_db.gridimage_geo
;
Sorry its awful.
No comments:
Post a Comment