sql statement questions

  • Thread starter Thread starter herewegoagain
  • Start date Start date
H

herewegoagain

Guest
I have successfully pulled all rows that are duplicated in my sql database.
Now I am trying to do two more things. I need to pull all COSTS (another
column) that are not equal in the duplicate fields where it gets it from a
textbox entry the user makes in a vb.net windows form. Here is the SQL
statement I have thus far:

If ComboBox3.Text = "Common Items" Then
sql2 = "SELECT *FROM JJKSUP WHERE NUMBER IN (SELECT NUMBER FROM JJKSUP GROUP
BY NUMBER HAVING COUNT(*)> 1 and LIKE " & TextBox1.Text & " ) ORDER BY
NUMBER"

SqlDataAdapter1 = New SqlClient.SqlDataAdapter(sql2,
SqlConnection1)
Dsjjkp1.EnforceConstraints = False
SqlDataAdapter1.Fill(Dsjjkp1.JJKSUP)

When I take out the LIKE portion it works fine in returning the duplicates.
How can I make it pull records the user specifies in the textbox?
One step further is to to ask it to display items where COST is different on
items(number) that are duplicated?
 
Okay I figured out how to pull all identical rows with the what the user specifies in the textbox. Now I need to pull within that result all items with the same NUMBER but with different costs. All help is appreciated!!!
Here is where I am at right now:
If ComboBox3.Text = "Common Items" Then
sql2 = "SELECT * FROM JJKSUP " & _
"WHERE NUMBER IN (SELECT NUMBER " & _
"FROM JJKSUP " & _
"GROUP BY NUMBER " & _
"HAVING COUNT(*)> 1 ) " & _
"and NUMBER LIKE " & TextBox4.Text & "% " & _
"ORDER BY NUMBER"
 
Back
Top