| | |
2 slelect statement in 1 query..HOW?
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi all,
I am fairly new when it comes to SQL... and i would like some help
I would like to run 2 select statements in the same time...in order to get my results in a table with 2 columns and 2 rows that shows me the result of my queries
1st query:
2nd query:
Any help would be appreciated.
I am fairly new when it comes to SQL... and i would like some help
I would like to run 2 select statements in the same time...in order to get my results in a table with 2 columns and 2 rows that shows me the result of my queries
1st query:
sql Syntax (Toggle Plain Text)
SELECT count(serviceid) FROM serviceslog WHERE serviceid='3' AND partition NOT LIKE '%test%' AND component NOT LIKE '%test%' AND component NOT LIKE '%do not bill%' AND occurence BETWEEN '2009-05-01 05:00:00' AND '2009-06-01 04:59:59' GROUP BY serviceid;
2nd query:
sql Syntax (Toggle Plain Text)
SELECT count(serviceid) FROM serviceslog WHERE serviceid='3' AND partition NOT LIKE '%test%' AND component NOT LIKE '%test%' AND component NOT LIKE '%do not bill%' AND occurence BETWEEN '2009-05-01 05:00:00' AND '2009-06-01 04:59:59' GROUP BY serviceid;
Any help would be appreciated.
Last edited by peter_budo; Jun 8th, 2009 at 10:40 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Mean something like this?
MySQL Syntax (Toggle Plain Text)
SELECT '1' as rownum, count(serviceid) as id FROM serviceslog WHERE serviceid='1' AND partition NOT LIKE '%test%' AND component NOT LIKE '%test%' AND component NOT LIKE '%do not bill%' AND occurence BETWEEN '2009-05-01 05:00:00' AND '2009-06-01 04:59:59' GROUP BY serviceid UNION SELECT '2' as rownum, count(serviceid) as id FROM serviceslog WHERE serviceid='3' AND partition NOT LIKE '%test%' AND component NOT LIKE '%test%' AND component NOT LIKE '%do not bill%' AND occurence BETWEEN '2009-05-01 05:00:00' AND '2009-06-01 04:59:59' GROUP BY serviceid
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
hi
If you want all same fields for different id than you can use 'in ' with where clause.
Thanks
If you want all same fields for different id than you can use 'in ' with where clause.
MySQL Syntax (Toggle Plain Text)
SELECT count(serviceid) as id FROM serviceslog WHERE serviceid IN ('1','2') AND partition NOT LIKE '%test%' AND component NOT LIKE '%test%' AND component NOT LIKE '%do not bill%' AND occurence BETWEEN '2009-05-01 05:00:00' AND '2009-06-01 04:59:59' GROUP BY serviceid
Thanks
![]() |
Similar Threads
- how to delete duplicate record in a table by using SQL query (MS SQL)
- If Statement Query (PHP)
- SQL statement help! (Visual Basic 4 / 5 / 6)
- SQL query program to edit records (MySQL)
- VB Select Statement Query (Visual Basic 4 / 5 / 6)
- SQL statement to query user input?? (MS Access and FileMaker Pro)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- ADO.Net SQL UPDATE using OleDBAdapter (C#)
- DataTable Name question (VB.NET)
Other Threads in the MySQL Forum
- Previous Thread: Compare 2 time values to get an approximate result
- Next Thread: Mysgl error please help
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm 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 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 music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql syntax techsupport thunderbird transparency virtualization





