1

I am getting elements from MySQL by using this query;

select * from bahis where onay='1' or onay='2' order by rand()

But elements can be same with this query. For example I have 3 values that matches with this query, A,B,C

it can generate A A B or A B C or A B B

But I want to generate them like A B C or C B A or B A C.

How can I do that?

1
  • I think this is not your complete query. you may have a group by command Commented Aug 14, 2012 at 18:26

2 Answers 2

1

As written, your query will not output any individual row more than once -- it will just return every row in a random order. If you're getting duplicates in the result, then your table must contain duplicates; if this is correct, and you just need to suppress them, use the DISTINCT modifier (e.g, SELECT DISTINCT * ...).

Sign up to request clarification or add additional context in comments.

Comments

1

use something like this

select * from 
(select * from bahis where onay='1' or onay='2' group by abc_field) s1
order by rand()

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.