Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Help with SQL Query

 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please if somebody can help me with a query.
I've the following tables

mysql> select * from menu;
+----+---------------+----------------------------+-----------+
| id | title | description | published |
+----+---------------+----------------------------+-----------+
| 39 | Vrienden | Hier zullen blaa van alles | 1 |
| 40 | Gekke Sites | Ik weet het niet man!!! | 1 |
| 41 | Online Stores | Dat is het | 1 |
+----+---------------+----------------------------+-----------+

mysql> select * from menu_item;
+----+-----------------------+-----------+----------+---------+
| id | title | published | ordering | menu_id |
+----+-----------------------+-----------+----------+---------+
| 25 | Damatec Web Solutions | 1 | 1 | 41 |
| 28 | Almorni | 0 | 3 | 40 |
| 29 | Wie zijn wij | 1 | 2 | 41 |
| 30 | Google | 1 | 4 | 39 |
+----+-----------------------+-----------+----------+---------+


mysql> select * from page;
+----+--------------+---------+---------------------+---------------------+
| id | title | content | created_date | modified_date |
+----+--------------+---------+---------------------+---------------------+
| 1 | Mijn Pagina | Test1 | 00-00-0000 00:00:00 | 00-00-0000 00:00:00 |
| 2 | Wie zijn wij | Test2 | 00-00-0000 00:00:00 | 00-00-0000 00:00:00 |
| 3 | Contact | Test3 | 00-00-0000 00:00:00 | 00-00-0000 00:00:00 |
+----+--------------+---------+---------------------+---------------------+

mysql> select * from page_menu_item;
+----+---------+--------------+
| id | page_id | menu_item_id |
+----+---------+--------------+
| 1 | 2 | 25 |
+----+---------+--------------+

mysql> select * from url;
+----+-----------------------+--------------+
| id | url | menu_item_id |
+----+-----------------------+--------------+
| 8 | http://website.com | 28 |
| 9 | http://yahoo.com | 29 |
| 10 | http://www.google.com | 30 |
+----+-----------------------+--------------+

I want a query to get the the following data if the menu item links to an internal page:
id | title | published | menu_id | page_id |

and the following data if the menu item links to an url:
id | title | published | menu_id | url_id | url


Thanks,

Abu
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
 
    Bookmark Topic Watch Topic
  • New Topic