0

I have a temporary table TEST_GROUP, from where I'm working its data to fill another one.

enter image description here

From this table, giving the example in the picture, my expected result is to group these three rows, so I can have a result like

INSERT INTO TABLEDATA Select * from TEST2 where (field1 = 'B') and (field2 = 'T') and (field3 != 'S' and field3 != '')

Easy to say that when the EXP = EQ only validates the VAL1, but when the EXP=NE should validate VAL1 and VAL2, even if VAL2 is empty.

Not so easy for me to get the expected result.

Can you provide some guidelines how to get the expected result?

asked May 28, 2015 at 21:52

1 Answer 1

0

There is no SQL that can directly perform what you have described. Instead...

Read that data into your programming language (PHP, Java, VB, etc) and use code to construct the statement in question. Then execute it.

Yes, a Stored Procedure could be constructed, but that might be messier.

answered Jun 7, 2015 at 16:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.