flyboeing Posted September 8, 2010 Share Posted September 8, 2010 Hello all, I am currently making a movements database for my aviation photos. In this database a store all the data: registration, airport, etc. Here is how it looks like: +--------------+---------+---------+ | Registration | Airport | Airline | +--------------+---------+---------+ | PH-BQA | EHAM | KLM | +--------------+---------+---------+ I also have a database with all the airport stored in it: +----+------+---------------------------------+ | ID | ICAO | Airport | +----+------+---------------------------------+ | 1 | EHAM | Amsterdam Schiphol (EHAM / AMS) | +----+------+---------------------------------+ I want to make it like this: When I hover my mouse over the EHAM, I want to show the full airport name (that is stored in database 2). How can I make this? I am not that familiar with php/mysql... Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/ Share on other sites More sharing options...
trq Posted September 8, 2010 Share Posted September 8, 2010 Are you sure you are talking about two databases and not just two tables within the same database? There is a massive difference. Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/#findComment-1108643 Share on other sites More sharing options...
flyboeing Posted September 8, 2010 Author Share Posted September 8, 2010 My mistake! I mean two tables in one database. Sorry Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/#findComment-1108650 Share on other sites More sharing options...
flyboeing Posted September 8, 2010 Author Share Posted September 8, 2010 I made a mistake in my question, it is not about 2 databases, it is 1 database with 2 tables. In the first table is de main information. The second table contains only the airport information. On my webpage only the ICAO code (4-letter) code is visible. When you hover over the 4-letter code, I want to show the compleet airport name. The hovering thing is already working for some other elements, but to get the full airport name from another table, I can't get that to work. Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/#findComment-1108724 Share on other sites More sharing options...
pengu Posted September 9, 2010 Share Posted September 9, 2010 You will need a LEFT JOIN. SELECT t2.Airport FROM Table1 AS t1 LEFT JOIN Table2 AS t2 ON t1.Airport = t2.ICAO /** Possible to add a WHERE clause, if you only want to select one airport **/ Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/#findComment-1108986 Share on other sites More sharing options...
flyboeing Posted September 9, 2010 Author Share Posted September 9, 2010 Thank you for your reply pengu. I will try it with the Left Join Link to comment https://forums.phpfreaks.com/topic/212853-get-data-from-another-database/#findComment-1109068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.