"Matthew Crouch" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Here's an easy one that I can't find laid out for me anywhere: > I want a self join that pairs up the id numbers of a table in every > permutation > > e.g. i have id #s 1, 2, and 3 > i need this result: > 1 2 > 1 3 > 2 1 > 2 3 > 3 2 > 3 1 > > clear enough?
Uh... haven't tested it, but seems likely: SELECT a.id, b.id FROM mytable AS a JOIN mytable AS b ON a.id != b.id 1. this could easily return a very VERY large result. 2. are {1,3} and {3,1} really different, or should you use ...ON a.id < b.id ? This would cut the size of your returned query by half. 3. there are probably much better means of accomplishing whatever you're trying to do. Just getting the list of ids and intersecting them in PHP sounds like a better approach to me. More information about what you're trying to accomplish would help. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php