0

I dont know how exactly to put the topic to fit what i want to achieve. If you can , kindly help restructure it.

I have a database whose structure looks like this

Transaction ID  tx_no
xxx 12
xxx 12
xxx 12
xxy 17
xxy 12
qqq 18
qqq 18
qqq 18
yty 15
yty 14
yty 15

I want to select the field where the transaction ID's are the same but the tr no is not the same all through for a transaction ID

e.g i want my query to select yty, xxy.

I would appreciate any help i can get with this either with php or mysql.

Thanks

2 Answers 2

1

This would be one way:

SELECT transactionid
FROM tablename
GROUP BY transactionid
HAVING COUNT(DISTINCT tx_no) > 1
Sign up to request clarification or add additional context in comments.

Comments

1
select transactionid
from tablename
group by transactionid
having max(tx_no) <> min(tx_no)

You can try this.

Comments

Your Answer

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.