aspose file tools*
The moose likes JDBC and the fly likes Help with SQL Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

Help with SQL Query

Azz Romaysa
Ranch Hand

Joined: Dec 08, 2004
Posts: 66
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Closing accidental duplicate.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with SQL Query