Re: help with query to count rows while excluding certain rows

2016-01-02 Thread Larry Martell
On Fri, Jan 1, 2016 at 9:31 PM, Peter Brawley wrote: > On 1/1/2016 19:24, Larry Martell wrote: >> >> On Fri, Jan 1, 2016 at 2:12 PM, Peter Brawley >> wrote: >>> >>> On 12/31/2015 0:51, Larry Martell wrote: I need to count the number of rows in a table that are grouped by a list of

Re: help with query to count rows while excluding certain rows

2016-01-01 Thread Larry Martell
On Fri, Jan 1, 2016 at 2:12 PM, Peter Brawley wrote: > On 12/31/2015 0:51, Larry Martell wrote: >> >> I need to count the number of rows in a table that are grouped by a >> list of columns, but I also need to exclude rows that have more then >> some count when grouped by a different set of columns

Re: help with query to count rows while excluding certain rows

2016-01-01 Thread Peter Brawley
On 12/31/2015 0:51, Larry Martell wrote: I need to count the number of rows in a table that are grouped by a list of columns, but I also need to exclude rows that have more then some count when grouped by a different set of columns. Conceptually, this is not hard, but I am having trouble doing th

help with query to count rows while excluding certain rows

2015-12-30 Thread Larry Martell
I need to count the number of rows in a table that are grouped by a list of columns, but I also need to exclude rows that have more then some count when grouped by a different set of columns. Conceptually, this is not hard, but I am having trouble doing this efficiently. My first counting query wo

Re: Need help with query

2011-03-23 Thread S�ndor Hal�sz
2011/03/15 17:51 -0500, LAMP Let's say there is a table orders (simplified, of course) CREATE TABLE orders ( item_id int, org_id int, ) ENGINE=MyISAM Need to select all (distinct) org_id they have item_id 34, 36, 58 and 63. All of them, not only some of them. Result is org_id=2

Re: Need help with query

2011-03-19 Thread Roy Lyseng
Hi! I think that the query that you have proposed is the best possible for the problem. However, if there are duplicates in the orders table, then HAVING COUNT(item_id) = 4 should be replaced with HAVING COUNT(DISTINCT item_id) = 4 (I assume that you meant item_id and not org_id in the COU

Re: Need help with query

2011-03-18 Thread S�ndor Hal�sz
2011/03/18 08:49 -0500, LAMP Is here anybody from mysql development team, to suggest to build IN ALL function? There is a problem here: the basic operation is on the record, each record by each record, all by itself. The solution to your problem entails acting on more distinc

Re: Need help with query

2011-03-18 Thread LAMP
On Mar 17, 2011, at 3:01 PM, Geert-Jan Brits wrote: Indeed, I don't thing there is. Just be sure that each record has an unique combination of org_id and item_id, otherwise you might end up with an org_id that, for example, references 4 times item_id 34 in 4 different records, but no oth

Re: Need help with query

2011-03-17 Thread LAMP
First I was thinking there is function IN ALL or something like that, since there are functions IN and EXISTS. And I would be able to make a query something like this select distinct org_id, item_id from orders where item_id in all (34, 36, 58, 63) order by org_id asc But, there

Re: Need help with query

2011-03-17 Thread Peter Brawley
> What I need is a list of orgs they bought all of items 34, 36, 58, 63. every of them. Some solutions under "What else did buyers of X buy" at http://www.artfulsoftware.com/infotree/queries.php. PB --- On 3/17/2011 12:00 PM, LAMP wrote: Yes, that was my question. Though, since English is n

Re: Need help with query

2011-03-17 Thread LAMP
Yes, that was my question. Though, since English is not my first language, let me try to post it again: There is a list of all orgs and items org bough, from table called orders item_idorg_id 342607 342607 341520 362607 361520 368934 38

Re: Need help with query

2011-03-15 Thread LAMP
On Mar 15, 2011, at 6:18 PM, Rhino wrote: All you should need is this: select distinct org_id from orders where item_id in (34, 36, 58, 63) I'm assuming that the DISTINCT operator is available in the version of MySQL that you are using. I don't currently have any version of MySQL instal

Need help with query

2011-03-15 Thread LAMP
Hi, I need a help to build a query. Let's say there is a table orders (simplified, of course) CREATE TABLE orders ( `item_id` int, `org_id` int, ) ENGINE=MyISAM item_idorg_id 342607 342607 341520 362607 361520 368934 3828 3815

Re: Help with query.

2011-02-02 Thread Simcha Younger
On Tue, 1 Feb 2011 14:46:39 -0400 Paul Halliday wrote: > I have a query (thanks to this list) that uses a join to add country > information to an IP. It looks like this: > > SELECT COUNT(signature) AS count, INET_NTOA(src_ip), map1.cc as > src_cc, INET_NTOA(dst_ip), map2.cc as dst_cc > FROM even

Re: Help with query.

2011-02-02 Thread Joerg Bruehe
Hi Paul! Paul Halliday wrote: > I have a query (thanks to this list) that uses a join to add country > information to an IP. It looks like this: > > SELECT COUNT(signature) AS count, INET_NTOA(src_ip), map1.cc as > src_cc, INET_NTOA(dst_ip), map2.cc as dst_cc > FROM event LEFT JOIN mappings AS m

Help with query.

2011-02-01 Thread Paul Halliday
I have a query (thanks to this list) that uses a join to add country information to an IP. It looks like this: SELECT COUNT(signature) AS count, INET_NTOA(src_ip), map1.cc as src_cc, INET_NTOA(dst_ip), map2.cc as dst_cc FROM event LEFT JOIN mappings AS map1 ON event.src_ip = map1.ip LEFT JOIN mapp

Re: help with query

2011-01-12 Thread Simon Wilkinson
Thank you, that did the trick. Simon On 11 January 2011 12:09, Steve Meyers wrote: > On 1/11/11 9:31 AM, Simon Wilkinson wrote: > >> select users.id from users where users.id in (select newletters.user_id >> from >> newletters left join articles on newletters.id = articles.newsletter_id >> wher

Re: help with query

2011-01-11 Thread Steve Meyers
On 1/11/11 9:31 AM, Simon Wilkinson wrote: select users.id from users where users.id in (select newletters.user_id from newletters left join articles on newletters.id = articles.newsletter_id where articles.newsletter_id is null); I think this would do what you require: SELECT u.id AS user_i

help with query

2011-01-11 Thread Simon Wilkinson
Hi, I have 3 tables that I am trying to search across, and could use some help on how to structure the query. I have a users table, a newsletter table, and an articles table. The newsletter table has a user_id column, and the articles table has a newsletter_id column. A user can have multiple n

Re: Need help with query optimization

2010-03-17 Thread John Daisley
It may only be returning 51 rows but its having to read significantly more. Get rid of the derived table join if possible. Something like SELECT TAP.ID , M.UID, TAP.FirstName, TAP.MI, TAP.LastName, TAP.State, TAP.SchoolName, TAP.StateApproved, TAP.DiplomatApproved, C.ChapterType,

Re: Need help with query optimization

2010-03-16 Thread Ananda Kumar
Can you please show us the indexes on both the tables. regards anandkl On Tue, Mar 16, 2010 at 11:47 PM, Jesse wrote: > I have the following query: > > SELECT TAP.ID , M.UID, TAP.FirstName, TAP.MI, > TAP.LastName, TAP.State, > TAP.SchoolName, TAP.StateApproved, TAP.DiplomatAppro

Need help with query optimization

2010-03-16 Thread Jesse
I have the following query: SELECT TAP.ID, M.UID, TAP.FirstName, TAP.MI, TAP.LastName, TAP.State, TAP.SchoolName, TAP.StateApproved, TAP.DiplomatApproved, C.ChapterType, S.Region, S.District,Pts.TotPoints FROM TorchAwardParticipants TAP JOIN Members M On M.ID=TAP.CurrentMemberID JOIN Chapters

Re: need help with query...

2008-12-17 Thread Lamp Lists
From: Andy Shellam To: Lamp Lists Cc: mysql@lists.mysql.com Sent: Wednesday, December 17, 2008 2:48:31 PM Subject: Re: need help with query... Hi, > > Hi Andy, > the reason I can't use this because fields (columns) in select statement &

Re: need help with query...

2008-12-17 Thread Andy Shellam
Hi, Hi Andy, the reason I can't use this because fields (columns) in select statement (p.first_name, p.last_name,...) are actually dynamically created. In my project different client will select different fields to be shown. 99% will select first_name, and last_name, but some don't care abo

Re: need help with query...

2008-12-17 Thread Andy Shellam
Jerry Schwartz wrote: -Original Message- From: Andy Shellam [mailto:andy-li...@networkmail.eu] Sent: Wednesday, December 17, 2008 3:29 PM To: Lamp Lists Cc: mysql@lists.mysql.com Subject: Re: need help with query... Hi Afan Why not prefix your field names with the table name? select

Re: need help with query...

2008-12-17 Thread Lamp Lists
From: Andy Shellam To: Lamp Lists Cc: mysql@lists.mysql.com Sent: Wednesday, December 17, 2008 2:29:08 PM Subject: Re: need help with query... Hi Afan Why not prefix your field names with the table name? select p.first_name AS person_first_name

RE: need help with query...

2008-12-17 Thread Jerry Schwartz
>-Original Message- >From: Andy Shellam [mailto:andy-li...@networkmail.eu] >Sent: Wednesday, December 17, 2008 3:29 PM >To: Lamp Lists >Cc: mysql@lists.mysql.com >Subject: Re: need help with query... > >Hi Afan > >Why not prefix your field names

RE: need help with query...

2008-12-17 Thread Jerry Schwartz
>-Original Message- >From: Lamp Lists [mailto:lamp.li...@yahoo.com] >Sent: Wednesday, December 17, 2008 2:57 PM >To: mysql@lists.mysql.com >Subject: need help with query... ...snip... >I have let say 3 tables people, organization, addresses. and they are >link

Re: need help with query...

2008-12-17 Thread Andy Shellam
Hi Afan Why not prefix your field names with the table name? select p.first_name AS person_first_name, p.last_name AS person_last_name, p.status AS person_status, p.date_registered AS person_date_registered, o.org_id AS organization_org_id, o.org_name AS organization_org_name, o.org_depar

Re: need help with query...

2008-12-17 Thread Jason Pruim
On Dec 17, 2008, at 2:56 PM, Lamp Lists wrote: I hate when somebody put in Subject line something like I just did but after 15 minutes to try to be specific just with one short sentence - I gave up. So, you can hate me - I understand (though, help with my problem too) :-) I have let say

need help with query...

2008-12-17 Thread Lamp Lists
I hate when somebody put in Subject line something like I just did but after 15 minutes to try to be specific just with one short sentence - I gave up. So, you can hate me - I understand (though, help with my problem too) :-) I have let say 3 tables people, organization, addresses. and they are

Re: Help with query

2008-12-15 Thread Néstor
Sorry!!! I apoligized for being blind. Yes, in my small mind I was thinking that I do not have records biggeer than 2008 but I do and my mind refused to see the records for 2009 and 2010. Sorry again for being so blind to the obvious. :-( On Mon, Dec 15, 2008 at 9:50 AM, Phil wrote: > Am I

Re: Help with query

2008-12-15 Thread Phil
Am I totally missing something? Why do you believe the two queries should return the same # of rows? First one has a qualification of proj_adv_date < '2008-12-16' whilst the second one does not... On Mon, Dec 15, 2008 at 12:12 PM, Néstor wrote: > I have a char fiel where I am keeping dates forma

Re: Help with query

2008-12-15 Thread John Daisley
Are you sure those are the results to those queries? ¢,m Your second query will return more because it includes values outside of the date range specified in the first query. In the second result set you have 2009 and 'invalid dates' that would not be picked up by the first query. Regards Joh

Help with query

2008-12-15 Thread Néstor
I have a char fiel where I am keeping dates formatted as year-month-day (2006-10-09) Now I am trying to find all the records between 2 strings (2 dates). The 2 queries below should return the same number of records by they do not. My query is this: SELECT COUNT(*) FROM proj where proj_archive=0

Re: Help with query to remove all records where foreign key doesn't have corresponding records

2008-08-13 Thread Brent Baisley
Just do a left join with the delete query. DELETE feed_tag FROM feed_tag LEFT JOIN feed ON feed_tag.feed_id=feed.id WHERE feed.id IS NULL That should do it. You can change "DELETE feed_tag" to "SELECT" and test it first. -- Brent Baisley On Aug 13, 2008, at 4:51 PM, Daevid Vincent wrote

Re: Help with query to remove all records where foreign key doesn't have corresponding records

2008-08-13 Thread Isart Montane
Hi Daevid If you are using a foreign key you can set the reference as "cascade" and when a row is deleted from feed it will be deleted from feed_tag. http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html If you don't like it you can delete it easy with a query like this del

Help with query to remove all records where foreign key doesn't have corresponding records

2008-08-13 Thread Daevid Vincent
I want to remove all records from 'feed_tag' where the feed_id foreign key doesn't have any corresponding records in feed. For instance I may have a record in feed_tag that is like (23, 10, 4543, '... (some date)'). Then lets say there is no record in feed that has a primary id key of 10. I w

Re: Help with query MySQL and PHP

2008-07-03 Thread Ananda Kumar
you can do some thing like this. create table new_table(id int, hair varchar(50),eyes varchar(50)) select column1,column2,...from old_table; On 7/3/08, axis <[EMAIL PROTECTED]> wrote: > > This question is strictly related to the mysql query not the php code. > I need to either create a new tab

Re: Help with query MySQL and PHP

2008-07-03 Thread axis
This question is strictly related to the mysql query not the php code. I need to either create a new table from the old one or add columns. The thing is don't know how to do it. let me simplify things up: I need a query to retrieve values from the table PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS to a ne

Help with query MySQL and PHP

2008-07-02 Thread axis
Hi, I want to create a new column or table from queries of the values of columns I( already have. My table is : PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS products_id products_extra_fields_id products_extra_fields_value 1 1

help with query

2008-03-06 Thread Nacho Garcia
Hi, im having a lot of trouble with one query, i hope someone could give me a hand with this, i would be really grateful these are the tables: TABLE friends id_usr INT id_friend INT with INDEX on (id_usr,id_friend) TABLE status id_usr INT lastConnection (other irrelevant info) with INDEX on

Re: help with query optimization

2008-01-09 Thread Brent Baisley
Your biggest problem is probably the subquery/IN your are performing. You should change that to a join. And I don't know about using SQL_CALC_FOUND_ROWS in a full text query that's not boolean, and you shouldn't use it unless you have a LIMIT clause. SELECT SQL_CALC_FOUND_ROWS table_1.id,ta

help with query optimization

2008-01-04 Thread Eben
Hi, I have a query that has to run on a full text indexed table with many millions of records. I'm trying to figure out some optimizations for it. Here's the general query: SELECT SQL_CALC_FOUND_ROWS table_1.id,table_2.* FROM table_2 LEFT JOIN table_1 ON table_2.shared_id = table_1.shared_i

RE: Help with query, (question simplified as last mail was very complicated to understand :))

2007-12-30 Thread Martin Gainty
r does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.> Date: Sun, 30 Dec 2007 13:54:32 +0100> From: [EMAIL PROTECTED]> To: mysql@lists.mysql.com> Subject: Re: Help with query, (questi

Re: Help with query, (question simplified as last mail was very complicated to understand :))

2007-12-30 Thread Richard
Richard a écrit : Sorry about my last email which was long and not clear. This is what I want to do Join two tables on "code table1" = "code table3" where messageid = for example 28 table 1 contains : message from messageid --

Help with query, (question simplified as last mail was very complicated to understand :))

2007-12-28 Thread Richard
Sorry about my last email which was long and not clear. This is what I want to do Join two tables on "code table1" = "code table3" where messageid = for example 28 table 1 contains : message from messageid -- message1 |

SV: Help with query...

2007-10-14 Thread Anders Norrbring
NULL) Thanks for the hints, you who gave them.. ;) Anders. > - Original Message - > From: "Anders Norrbring" <[EMAIL PROTECTED]> > To: > Sent: Sunday, October 14, 2007 7:13 AM > Subject: Help with query... > > > > I'm trying to set up a

Re: Help with query...

2007-10-14 Thread mysql
Anders Norrbring wrote: I'm trying to set up a query, but I don't really get the result I expected, so can someone please help me out here? The query I've built is this: SELECT a1.username FROM accountuser AS a1 LEFT JOIN (freeaccounts AS f1, payments AS p1) ON (a1.username = p1.username AND p

Help with query...

2007-10-14 Thread Anders Norrbring
I'm trying to set up a query, but I don't really get the result I expected, so can someone please help me out here? The query I've built is this: SELECT a1.username FROM accountuser AS a1 LEFT JOIN (freeaccounts AS f1, payments AS p1) ON (a1.username = p1.username AND p1.username = f1.username)

Re: Help with Query

2007-05-07 Thread Baron Schwartz
Hi Ed, Ed Curtis wrote: I need to get some duplicate record information from a table and I haven't found any way to do it yet. I figured there might be some type of query I could do using a "for each" type command. What I have is a table with names and companies. Some people have multiple en

Help with Query

2007-05-07 Thread Ed Curtis
I need to get some duplicate record information from a table and I haven't found any way to do it yet. I figured there might be some type of query I could do using a "for each" type command. What I have is a table with names and companies. Some people have multiple entries for different compan

Re: Need help with query

2007-05-01 Thread Mark Leith
Jesse wrote: COALESCE(CampCount.Cnt,0) + COALESCE(CounselorCount.Cnt,0) as GT Duuuh. Why didn't I think of that. What is MySQL's issue with referring to the variables ("As" assignments, whatever you want to call them)? I've had issues like this in situations like this one, when trying to

Re: Need help with query

2007-05-01 Thread Jesse
COALESCE(CampCount.Cnt,0) + COALESCE(CounselorCount.Cnt,0) as GT Duuuh. Why didn't I think of that. What is MySQL's issue with referring to the variables ("As" assignments, whatever you want to call them)? I've had issues like this in situations like this one, when trying to use them in the

Re: Need help with query

2007-05-01 Thread Baron Schwartz
Hi Jesse, Jesse wrote: The following query works just fine: SELECT B.BusNum, COALESCE(CampCount.Cnt,0) As Kids, B.CamperCapacity, COALESCE(CounselorCount.Cnt,0) As Adults, B.AdultCapacity FROM Buses B LEFT JOIN (SELECT BusID,Count(*) As Cnt FROM Campers GROUP BY BusID) AS CampCount ON Camp

Need help with query

2007-05-01 Thread Jesse
The following query works just fine: SELECT B.BusNum, COALESCE(CampCount.Cnt,0) As Kids, B.CamperCapacity, COALESCE(CounselorCount.Cnt,0) As Adults, B.AdultCapacity FROM Buses B LEFT JOIN (SELECT BusID,Count(*) As Cnt FROM Campers GROUP BY BusID) AS CampCount ON CampCount.BusID=B.ID LEFT J

RE: help with query: select customers that ARO NOT in orders t

2006-10-23 Thread Waldemar Jankowski
20, 2006 1:53 PM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: Re: help with query: select customers that ARO NOT in orders table On Fri, 20 Oct 2006, [EMAIL PROTECTED] wrote: hi to all, I have table customers (PK cust_id) I have table orders (PK order_id, FK cust_id) I need query t

RE: help with query: select customers that ARO NOT in orders table

2006-10-23 Thread Jerry Schwartz
, CT 06032 860.674.8796 / FAX: 860.674.8341 > -Original Message- > From: Waldemar Jankowski [mailto:[EMAIL PROTECTED] > Sent: Friday, October 20, 2006 1:53 PM > To: [EMAIL PROTECTED] > Cc: mysql@lists.mysql.com > Subject: Re: help with query: select customers that ARO NOT

Re: help with query: select customers that ARO NOT in orders table

2006-10-20 Thread Waldemar Jankowski
On Fri, 20 Oct 2006, [EMAIL PROTECTED] wrote: Ok. Just found I gave wrong info. To make my life easier, the person who created db named cust_id in 'orders' table as SoldTo [EMAIL PROTECTED] in this case, select cust_id from customers where cust_id not in (select Soldto from orders); will no

Re: help with query: select customers that ARO NOT in orders table

2006-10-20 Thread afan
Ok. Just found I gave wrong info. To make my life easier, the person who created db named cust_id in 'orders' table as SoldTo [EMAIL PROTECTED] in this case, select cust_id from customers where cust_id not in (select Soldto from orders); will not work :( > On Fri, 20 Oct 2006, [EMAIL P

Re: help with query: select customers that ARO NOT in orders table

2006-10-20 Thread Waldemar Jankowski
On Fri, 20 Oct 2006, [EMAIL PROTECTED] wrote: hi to all, I have table customers (PK cust_id) I have table orders (PK order_id, FK cust_id) I need query that will selecct all customers from 'customers' they don't have any order, there is not their cust_id in 'orders'. couls somebody help me? t

help with query: select customers that ARO NOT in orders table

2006-10-20 Thread afan
hi to all, I have table customers (PK cust_id) I have table orders (PK order_id, FK cust_id) I need query that will selecct all customers from 'customers' they don't have any order, there is not their cust_id in 'orders'. couls somebody help me? thanks. -afan -- MySQL General Mailing List For

Re: Help with query

2006-09-26 Thread Visolve DB Team
ot;Ed Curtis" <[EMAIL PROTECTED]> To: Sent: Monday, September 25, 2006 11:47 PM Subject: Help with query > > I'm trying to do a keyword search within a phrase saved in a table. > > Here's the query: > > SELECT * from closedtickets WHERE > > k

RE: Help with query

2006-09-25 Thread Jerry Schwartz
Curtis [mailto:[EMAIL PROTECTED] Sent: Monday, September 25, 2006 2:18 PM To: mysql@lists.mysql.com Subject: Help with query I'm trying to do a keyword search within a phrase saved in a table. Here's the query: SELECT * from closedtickets WHERE keyphrase LIKE '%$keyword1%'

Help with query

2006-09-25 Thread Ed Curtis
I'm trying to do a keyword search within a phrase saved in a table. Here's the query: SELECT * from closedtickets WHERE keyphrase LIKE '%$keyword1%' OR keyphrase LIKE '%$keyword2%' OR keyphrase LIKE '%$keyword3%' The problem I'm having is that the query is returning every record in th

Re: Help with query

2006-08-21 Thread Jesse
. I really appreciate your help. Jesse - Original Message - From: Douglas Sims To: Jesse Cc: MySQL List Sent: Monday, August 21, 2006 12:07 PM Subject: Re: Help with query I think you are trying to use a regular expression in the like phrase. I wasn't aware that MS SQL

Re: Help with query

2006-08-21 Thread Douglas Sims
I think you are trying to use a regular expression in the like phrase. I wasn't aware that MS SQL can do regular expressions at all? I've been using 2000 - perhaps the newer version can? In MySQL, instead of saying: LA.LastName LIKE '[A-E]%' try this: LA.LastName REGEXP '^[A-E]' You can

Help with query

2006-08-21 Thread Jesse
I have the following query which works in MS SQL Server, but I'm sure the syntax is different for Myself. I'm sure it's in the area of the "LIKE" clause. I don't know how to do this with Myself. Can anyone point me in the right direction?: SELECT LA.FirstName,LA.LastName,LA.EMailAddress, LA

Re: Help with query: Row number / Rank from a query...

2006-06-02 Thread Dan
Thanks Peter, That looks pretty good to me. I never would have figured that out on my own. Dan T On Jun 1, 2006, at 4:06 PM, Peter Brawley wrote: Dan, >I want to get a particular users 'rank' or row number from the query. SELECT 1+COUNT(*) AS Rank FROM results r1 INNER JOIN results r2 O

Re: Help with query: Row number / Rank from a query...

2006-06-01 Thread Peter Brawley
Dan, >I want to get a particular users 'rank' or row number from the query. SELECT 1+COUNT(*) AS Rank FROM results r1 INNER JOIN results r2 ON r1.points I have a regular query lets say: SELECT user, points FROM results ORDER BY points DESC so I get: userpoints --- john23 s

Re: Help with query: Row number / Rank from a query...

2006-06-01 Thread Michael Stassen
Dan wrote: I have a regular query lets say: Better to show the real query, rather than a simplified version. Simplified requests get you simplified answers. What seems like a simplification to you, may in fact hide a crucial piece of information, thus preventing anyone from giving you a so

Help with query: Row number / Rank from a query...

2006-06-01 Thread Dan
I have a regular query lets say: SELECT user, points FROM results ORDER BY points DESC so I get: userpoints --- john23 steve 17 bill14 From this I want to get a particular users 'rank' or row number from the query. I was hoping for a single line elegant query for t

Re: Help with Query Optimization

2006-02-28 Thread Peter Brawley
Kishore, > We use Vbulletin for our message boards, and I have a query which >takes approximately 1.2 - 1.5 seconds to execute, on a table ('thread') >having around 130,000 rows, it is as follows >SELECT threadid >FROM thread >LEFT JOIN deletionlog >ON ( thread.threadid = deletionlog

Help with Query Optimization

2006-02-28 Thread Kishore Jalleda
Hi All, We use Vbulletin for our message boards, and I have a query which takes approximately 1.2 - 1.5 seconds to execute, on a table ('thread') having around 130,000 rows, it is as follows SELECT threadid FROM thread AS thread LEFT JOIN deletionlog AS deletionlog ON ( thread.threadid =

Re: help with query

2006-02-21 Thread Peter Brawley
>how to achieve this? >select table1.*, table2.*, table3.*, sum(table2.field3), sum(table2.field4) >from table1, table2, table3 where table1.field1 = table2.field1 and >table2.field1 = table3.field1 Your question as formulated has no answer. If you query aggregate values like Sum on a table, y

help with query

2006-02-21 Thread xtcsuk
3 tables: table1 -> table2 (one to many) table2 -> table3 (one to one) [designed like this] how to achieve this? select table1.*, table2.*, table3.*, sum(table2.field3), sum(table2.field4) from table1, table2, table3 where table1.field1 = table2.field1 and table2.field1 = table3.field1 regards

Re: Help with query optimization & query SUM

2006-02-06 Thread سيد هادی راستگوی حقی
Dear Reynier, You can use JOIN on your both, The JOIN have to run on the same feilds i.e IDA. SELECT * FROM carro_de_compras LEFT JOIN os_articulo ON carro_de_compras.IDA = os_articulo.IDA This query returns all your users with their articles if any and you can iterate on it. but one note: Use

Help with query optimization & query SUM

2006-02-06 Thread Reynier Perez Mira
Hi: I'm develop a simple shopping cart. I have this two tables: carro_de_compras -- IDU int(11) NOT NULL IDA int(11) NOT NULL CantidadDeArticulos int(11) NOT NULL os_articulo -- IDA int(11) NOT NULL auto_increment, IDC int(11) NOT NULL default '0', ANombre varchar(200) NOT NULL def

Re: Help with query

2006-01-25 Thread SGreen
Jay Paulson <[EMAIL PROTECTED]> wrote on 01/25/2006 10:09:36 AM: > From the result set below I have 22 rows and the only difference is the > date. I was wondering if there was a way to get all of these results using > GROUP BY instead of having to use LIMIT?? > > As this table grows I'm going t

Help with query

2006-01-25 Thread Jay Paulson
>From the result set below I have 22 rows and the only difference is the date. I was wondering if there was a way to get all of these results using GROUP BY instead of having to use LIMIT?? As this table grows I'm going to want to get a LIMIT 0,77 but would like it to be grouped by date. So basi

Re: help with query

2005-10-22 Thread Peter Brawley
ja, Your question is a little cryptic. If a questionid column value identifies a particular question, and a vote column value contains a user's vote (1,2,3, &c), can't you just write... SELECT questionid, vote,count(vote) FROM ... GROUP BY questionid, vote PB - [EMAIL PROTECTED] wrote:

Re: help with query

2005-10-22 Thread SGreen
<[EMAIL PROTECTED]> wrote on 10/22/2005 06:24:07 PM: > > > I have a table of votes with four fields, a primary key, and userID, > that are just there for tracking purposes. But then I have > questionID and vote fields. For each question, a user could pick a > number of it's importance from 1

help with query

2005-10-22 Thread jabbott
I have a table of votes with four fields, a primary key, and userID, that are just there for tracking purposes. But then I have questionID and vote fields. For each question, a user could pick a number of it's importance from 1 to 5. That number is what gets stored in the vote field. So,

Re: Help with query

2005-10-13 Thread Dušan Pavlica
Shawn, - Original Message - From: [EMAIL PROTECTED] To: Dušan Pavlica Cc: Michael Stassen ; list mysql Sent: Wednesday, October 12, 2005 4:45 PM Subject: Re: Help with query Dušan Pavlica <[EMAIL PROTECTED]> wrote on 10/12/2005 10:00:53 AM: > Thanks, Mi

Re: Help with query

2005-10-12 Thread SGreen
ECTED]> > To: "Dušan Pavlica" <[EMAIL PROTECTED]> > Cc: "list mysql" > Sent: Wednesday, October 12, 2005 2:54 PM > Subject: Re: Help with query > > > > Dušan Pavlica wrote: > >> Hello, > >> > >> could someone help me

Re: Help with query

2005-10-12 Thread Dušan Pavlica
t want to write querries for each DB system separately. Now I see that I will have to. Dusan - Original Message - From: "Michael Stassen" <[EMAIL PROTECTED]> To: "Dušan Pavlica" <[EMAIL PROTECTED]> Cc: "list mysql" Sent: Wednesday, October 12, 2

Re: Help with query

2005-10-12 Thread Michael Stassen
Dušan Pavlica wrote: Hello, could someone help me please to construct correct query or tell me what I'm doing wrong? I have three tables: table products table products_codes where some products could have assigned another additional codes table products_prices I want to get all rows from pro

Help with query

2005-10-12 Thread Dušan Pavlica
Hello, could someone help me please to construct correct query or tell me what I'm doing wrong? I have three tables: table products table products_codes where some products could have assigned another additional codes table products_prices I want to get all rows from product_prices listed wit

Re: Help with query using IN()

2005-10-05 Thread Felix Geerinckx
On 04/10/2005, Jasper Bryant-Greene wrote: > Kishore Jalleda wrote: > > Could you kindly advice if this query can be made to run faster > > SELECT title, template > > FROM template > > WHERE templateid IN > > (608,2072,2073,1888,1898,1895,1897,1894,1896,1901,1903,1889,1900,189 > > 0,1891,1902,1904

Re: Help with query using IN()

2005-10-04 Thread Jasper Bryant-Greene
Kishore Jalleda wrote: Could you kindly advice if this query can be made to run faster SELECT title, template FROM template WHERE templateid IN (608,2072,2073,1888,1898,1895,1897,1894,1896,1901,1903,1889,1900,1890,1891,1902,1904,2104,624,625,2152,2212,1985,1996,614,1964,2103,2106,2113,1982,1983

Help with query using IN()

2005-10-04 Thread Kishore Jalleda
Hi All, Could you kindly advice if this query can be made to run faster SELECT title, template FROM template WHERE templateid IN (608,2072,2073,1888,1898,1895,1897,1894,1896,1901,1903,1889,1900,1890,1891,1902,1904,2104,624,625,2152,2212,1985,1996,614,1964,2103,2106,2113,1982,1983,1984,2074,623,21

Re: Help with query

2005-05-16 Thread Ronan Lucio
Mathias, To drop multiple IP, you can use distinct : mysql> SELECT year, month, day, group_concat(distinct ip),count(*) AS access -> FROM access -> WHERE year = 2005 -> AND month = 5 -> GROUP BY year, month,day -> ORDER BY year, month, day; +--+---+--+---

Re: Help with query

2005-05-16 Thread mfatene
Hi Ronan, I don't know if i understand your need, but your query gives something like that : mysql> SELECT year, month, day, ip, COUNT(*) AS access -> FROM access -> WHERE year = 2005 -> AND month = 5 -> GROUP BY year, month, day, ip -> ORDER BY year, month, day; +--

Re: Help with query

2005-05-16 Thread SGreen
"Ronan Lucio" <[EMAIL PROTECTED]> wrote on 05/16/2005 04:21:17 PM: > Mathias, > > > Hi, > > look at group by ... with rollup at : > > http://dev.mysql.com/doc/mysql/en/group-by-modifiers.html > > Thank you very much for your help. > > My needs aren´t this, exactly. > > GROUP BY WITH ROLLUP, re

Re: Help with query

2005-05-16 Thread Ronan Lucio
Mathias, Hi, look at group by ... with rollup at : http://dev.mysql.com/doc/mysql/en/group-by-modifiers.html Thank you very much for your help. My needs aren´t this, exactly. GROUP BY WITH ROLLUP, returns me several lines of the same day (one per IP), plus the total. I need that every year-month-da

Re: Help with query

2005-05-16 Thread mfatene
Hi, look at group by ... with rollup at : http://dev.mysql.com/doc/mysql/en/group-by-modifiers.html Mathias Selon Ronan Lucio <[EMAIL PROTECTED]>: > Hello, > > I have a table where is saved all site´s access: > > access > > id > year > month > day > weekday > hour > minute > ip > > Any colu

Help with query

2005-05-16 Thread Ronan Lucio
Hello, I have a table where is saved all site´s access: access id year month day weekday hour minute ip Any column has multiple lines, and I have the follow query that returns the amount of access per day of month: SELECT year, month, day, COUNT(*) AS access FROM access WHERE year = 2005 AND

Help with query

2005-03-02 Thread Ryan Schefke
Hello, I have two tables: Table2 (listings), columns - listingID, state, preferred, siteAddress, siteTitle, siteDescription Table1 (invotes), columns listingID I want to select the listingID of the rows in Table2 where the 'state' column equals '$st' then count the number of rows in Ta

Re: !! Help with query: Where Date = MAX(Date)

2005-02-04 Thread Michael Dykman
On Fri, 2005-02-04 at 09:19, Graham Cossey wrote: > Could someone please offer a little help. > > I have a table like: > > Year, Month, Start_date > 20041020041102 > 20041120041203 > 20041220050104 > 20050120050204 > 20050220050303 > > I need to get the la

RE: !! Help with query: Where Date = MAX(Date)

2005-02-04 Thread Graham Cossey
> > As I'm using 4.0.20 I can't use subqueries so how can I create > a query that > > does this? > > > > SELECT year, month > > FROM `dc_months` > > WHERE start_date = (SELECT MAX(start_date) > > from dc_months > > where start_date <= '20050204') > >

  1   2   >