Hello,
We have two tables and I need values from table2 merged with those in table 1 where bus_id in Table1 equals bus_id in Table2
In Table1 the bus_id are unique, they only appear once in the colum.
In table2 there are duplicates of bus_id, because each row where the bus_id appears stores a different URL in the the URL column
As a for instance: In table2 there may be 5 instances of the bus_id or there may be some with up to 40 bus_id, again each storing a different URL
in table2 there is also a column which says "default" and the values in this column are either "y" or "n"
Example of table 2
bus_id URL Default
233 URL1 n
233 URL2 n
233 URL3 y
233 url4 n
1838 url8 n
44 url66 y
44 url88 n
Example of table 1
bus_id value1 value2
122
224
233
1838
44
Desired Table
bus_id value1 value2 Default_URL URL1 Url2.....url9 ThumbnailURl
122
224
233 url3 URl1 url2 someURL
1838 url18
44 url166 url88 someUrL
SEE ATTACHMENT for example of the [login to view URL], layout got messed up posting here.
In my desired table I'd like to have the Default_URL and ThumbnailURL values = to the appropriate URLs from table2 ONLY when DEFAULT=y for that bus_id
The Desired table will include all the values from Table 1 and then merge/join(not sure of right terminology) the values from Table 2 where Table1.bus_id = Table2bus_id
I am a litte new to MySQL queries but here is my best stab at what queries would/could be done, but I don't know how to get the multple instance "join" onto the new table. Plus right now the data is stored in two text files and I can't even begin to figure out how to do this in Excel or Access, then convert it to a csv file for import. one of the problems is that Table1 is table2 has over 2 million records (503MB) and table1 has 92k records (206Mb)
SET Desiredtable.Default_Url=[login to view URL]
WHERE (table1.busid=[login to view URL] AND table2.default=y)
SET DesiredTable.ThumbnailURL=[login to view URL]
WHERE table2.busid=[login to view URL] AND Default=y
Join [login to view URL] to table1
WHERE table2.bus_id=[login to view URL] AND Default!=y NOTE:the maximum number of new columns needed is 9 as there may be some instance where this condition is true up to 40+times but again we only need a maximum of 9 values copied that meet this condition)
So of those table2.bus_id's with more than 9 or 10 values for URL, we will only need the first 9 or 10, and the rest wont get used.
The resultant table needs to be submitted in CSV format. A copy of the script(s) used is also desired.
OK - having gone over the requirements I think I have a good idea of how to go about what you want. Here's what you want as I understand it:
- you have two tables (one in Access, one in MySQL) that you want combining into one
- once the new table has been created, you want the results exported to CSV format.
- the "default url" field is set to the appropriate url from table 2
- each record from the new table should only have the first 10 urls in it and the rest shouldn't be included.
If this is the case then I'd be happy to take this on for you.
Please consider my bid.
Thanks.
Mike
I am a MySQL certified DBA with extensive experience mass importing data from plain text files and writing the queries needed to create the final combined table you need. I will include details of how I performed the job to you in order to help you learn how to take on similar tasks in the future yourself.