| | |
help - ordering
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 24
Reputation:
Solved Threads: 0
Hello! I need some help please..
i searched a lot, and tried everything... can someone help me please..
here's the deal:
i have this select:
it's output:
http://i.imagehost.org/0746/tabela.jpg
but what i really want is:
i want to select my client's, but where local_id is the last id i receive.. but i don't wanna show repetitive client's, i just want to show the last local_id for each client....
i want like to show only this ones: http://i.imagehost.org/0883/tabela2.jpg in the red circle
you know what i mean?
it's like two order by's but not showing repetitive client's... i tried distinct... but maybe im making it wrong..
help :s
thanks a lot
i searched a lot, and tried everything... can someone help me please..
here's the deal:
i have this select:
MySQL Syntax (Toggle Plain Text)
SELECT * FROM localizacao, cliente, dispositivo WHERE disp_id = clien_disp_id AND disp_id = local_disp_id ORDER BY local_id desc
it's output:
http://i.imagehost.org/0746/tabela.jpg
but what i really want is:
i want to select my client's, but where local_id is the last id i receive.. but i don't wanna show repetitive client's, i just want to show the last local_id for each client....
i want like to show only this ones: http://i.imagehost.org/0883/tabela2.jpg in the red circle
you know what i mean?
it's like two order by's but not showing repetitive client's... i tried distinct... but maybe im making it wrong..
help :s
thanks a lot
Last edited by gpss; Oct 21st, 2009 at 12:53 pm.
0
#2 Oct 22nd, 2009
This was a good exercise! This code will do what you want:
MySQL Syntax (Toggle Plain Text)
SELECT #localizacao.*, #cliente.*, #dispositivo.* FROM #dispositivo JOIN #localizacao on #localizacao.local_disp_id = #dispositivo.disp_id JOIN #cliente on #cliente.clien_disp_id = #dispositivo.disp_id JOIN ( SELECT max(local_id) as localid, clien_id, local_disp_id FROM #localizacao, #cliente, #dispositivo WHERE disp_id = clien_disp_id AND disp_id = local_disp_id GROUP BY local_disp_id, clien_id ) as a on a.localid=#localizacao.local_id and a.clien_id=#cliente.clien_id and a.local_disp_id=#dispositivo.disp_id
All opinions 100% correct. Or your money back.
![]() |
Similar Threads
- Pizza ordering system (PHP)
- Sequence diagram for online ordering system (Computer Science)
- ordering arrays (C++)
- Ordering Pizza (Geeks' Lounge)
- priority queue ordering (C++)
- Ordering arrays? (C)
- Ordering an array (Java)
- IE 7 and existing online ordering system not working (JavaScript / DHTML / AJAX)
Other Threads in the MySQL Forum
- Previous Thread: SQL Server 2005 error
- Next Thread: Inserting data to mysql database using php created form
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api aws bizspark breathalyzer changingprices cmg communityjournalism contentmanagement contractors copyright count court crm data database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





