Jump to content
Xtreme .Net Talk

sql statement questions


Recommended Posts

Guest herewegoagain
Posted

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?

Guest herewegoagain
Posted

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"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...