If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Select query not giving expected output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-11, 11:24
Vijay2482 Vijay2482 is offline
Registered User
 
Join Date: Oct 2009
Posts: 1
Select query not giving expected output

I'm working on a vb.net application, where I use sql queries to get the datas from a dbase file.

There are cases where there can be 2 similar rows with the PARENT and ENFANT fields same in E_Ensart table, but the other columns may ahve different datas.

I use the below query to retrive datas from the database:
Code:
 Private Function GetSQLExactMatch(ByVal name As String, ByVal artTbl As String) As String
        Dim sb As StringBuilder = New StringBuilder("")
        sb.Append(GetSQLSelectColumns())
        sb.Append(" from E_Ensemb e,  ")
        sb.Append("  E_Ensart a ")
        sb.Append(" where a.PARENT = '" & name & "' ")
        sb.Append(" and e.ITEM_NBR = a.ENFANT ")
        sb.Append("   and a.VALIDITE = 'O'")
        Return sb.ToString()
    End Function
When I use the above query, I get only one line from E_Ensart table instead of 2 lines.
I think its because I assign the e.ITEM_NBR =a.ENFANT in my query.
But even if I remove this line, I get only one row picked instead of 2 rows and I also find that the query is running indefinitly and the same line is repeated n number of times...

Kindly help me to find out where I'm wrong.
Hoping for suggestions.
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 05-19-11, 12:57
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Maybe there is a generic SQL answer to your problem that someone here can help you with, but be aware that this DB2 forum has nothing to do with dbase. This forum is for the IBM DB2 database product.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 05-19-11, 13:02
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
do you maybe need an AND/OR condition? Parent = ? OR enfant = ?
Dave Nance
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On