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
Bookmark "Help with SQL Query" Watch "Help with SQL Query" 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



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
[ January 31, 2007: Message edited by: Azz Romaysa ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Abu,
What do you have so far? Post that along with what you are stuck on and we can help you more.


[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
Abdulla Mamuwala
Ranch Hand

Joined: Jan 09, 2004
Posts: 225
hey azz, I agree with what Jeanne says you need to show some work man !!! By the looks of it you may want to check out the Table Join concept. chill
Azz Romaysa
Ranch Hand

Joined: Dec 08, 2004
Posts: 66
Hello,

This is what I've so far


It always returns an empty table.

What I want is the following result when menu_item_id = 30:


Or this one when menu_item_id = 25:


What is the query that I should have?
P.S. The menu_item cannot have an url_id and a page_id

Regards,
Azz
[ February 01, 2007: Message edited by: Azz Romaysa ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Azz,
Your query is good first step. It sets up the join structure.

There is a concept called an outer join. The syntax varies by database. You can find the syntax by looking at your documentation or googling your database and "outer join". The concept is the same across databases.
Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
Hope this helps... I havent tested it...



Thanks and Regards,
Arul.
Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
More Simpler one...

Azz Romaysa
Ranch Hand

Joined: Dec 08, 2004
Posts: 66
Thank you guys,

This is the query that worked for me:


Arulanand: your last query returned always an empty row.

My problem now is how can I update all these tables once. Could somebody help me?

Kind Regards,

Azz
[ February 06, 2007: Message edited by: Azz Romaysa ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with SQL Query