Re: Problem with WHERE .. IN

2010-12-20 Thread Dan Nelson
In the last episode (Dec 20), Johnny Withers said: > On Mon, Dec 20, 2010 at 11:52 AM, muhammad subair wrote: > > I have table post (id INT and parent VARCHAR) > > > > +--+-+ > > | id | parent | > > +--+-+ > > |1 | 0 | > > |2 | 0 |

Re: Problem with WHERE .. IN

2010-12-20 Thread Johnny Withers
The sub-select only returns a single row, so IN(...) is only looking at a single value in the list .. it doesn't "expand" to into IN (5,7,11). On Mon, Dec 20, 2010 at 11:52 AM, muhammad subair wrote: > I have table post (id INT and parent VARCHAR) > > +--+-+ > | id | parent

Problem with WHERE .. IN

2010-12-20 Thread muhammad subair
I have table post (id INT and parent VARCHAR) +--+-+ | id | parent | +--+-+ |1 | 0 | |2 | 0 | |3 | 1 | |4 | 0 | |5 | 1 | |6 | 0 | |7 | 1,5 | |8 | 1,5 |

RE: SELECT WHERE IN help

2010-09-21 Thread Jerry Schwartz
>-Original Message- >From: Tompkins Neil [mailto:neil.tompk...@googlemail.com] >Sent: Tuesday, September 21, 2010 11:48 AM >To: Johan De Meersman >Cc: [MySQL] >Subject: Re: SELECT WHERE IN help > >Thanks for the reply. The search of (3,4,5,6,7,3) is pulling data

Re: SELECT WHERE IN help

2010-09-21 Thread Joerg Bruehe
Hi Neil, all! Tompkins Neil wrote: > Hi > > With a SELECT * FROM my_table WHERE record_id IN (3,4,5,6,7,3), how can I > return two records for the record_id 3 ? Is it possible ? This is a case where you may safely use natural language and logic. The command is SELECT all fields FROM the rec

Re: SELECT WHERE IN help

2010-09-21 Thread Mark Goodge
On 21/09/2010 16:44, Tompkins Neil wrote: Thanks for the quick reply. Basically in (3,4,5,6,7,3) the record_id of 3 only exists once in the table my_table. However, because 3 exists twice within (3,4,5,6,7,3), I want it to return two records for record_id 3. Is it possible ? No, that isn't

Re: SELECT WHERE IN help

2010-09-21 Thread Tompkins Neil
Thanks for the reply. The search of (3,4,5,6,7,3) is pulling data from a table. I think in this case I need to change my design . On Tue, Sep 21, 2010 at 4:46 PM, Johan De Meersman wrote: > I don't think that'll work, no. Why would you want to return duplicate data > ? The whole point of an R

Re: SELECT WHERE IN help

2010-09-21 Thread Johan De Meersman
I don't think that'll work, no. Why would you want to return duplicate data ? The whole point of an RDBMS is to *avoid* duplicate data :-) On Tue, Sep 21, 2010 at 5:44 PM, Tompkins Neil wrote: > Thanks for the quick reply. Basically in (3,4,5,6,7,3) the record_id of 3 > only exists once in the

Re: SELECT WHERE IN help

2010-09-21 Thread Tompkins Neil
Thanks for the quick reply. Basically in (3,4,5,6,7,3) the record_id of 3 only exists once in the table my_table. However, because 3 exists twice within (3,4,5,6,7,3), I want it to return two records for record_id 3. Is it possible ? Cheers Neil On Tue, Sep 21, 2010 at 4:40 PM, Johan De Meers

Re: SELECT WHERE IN help

2010-09-21 Thread Johan De Meersman
If there are two, you will return two. On Tue, Sep 21, 2010 at 5:33 PM, Tompkins Neil wrote: > Hi > > With a SELECT * FROM my_table WHERE record_id IN (3,4,5,6,7,3), how can I > return two records for the record_id 3 ? Is it possible ? > > Cheers > Neil > -- Bier met grenadyn Is als mosterd

SELECT WHERE IN help

2010-09-21 Thread Tompkins Neil
Hi With a SELECT * FROM my_table WHERE record_id IN (3,4,5,6,7,3), how can I return two records for the record_id 3 ? Is it possible ? Cheers Neil

Re: Should I be able to DELETE FROM ... WHERE .. IN ( ... ) with multiple a column key?

2009-05-31 Thread Moon's Father
Mudd wrote: > >> > So is the format of the DELETE FROM .. WHERE ... IN ( ... ) clause I > >> > propose valid and SHOULD the optimiser recognise this and be expected > >> > to just find the 2 rows by searching on the primary key? > >> > >>

Re: Should I be able to DELETE FROM ... WHERE .. IN ( ... ) with multiple a column key?

2009-05-27 Thread Baron Schwartz
Simon, On Wed, May 27, 2009 at 11:23 AM, Simon J Mudd wrote: > per...@elem.com (Perrin Harkins) writes: > >> On Wed, May 27, 2009 at 6:43 AM, Simon J Mudd wrote: >> > So is the format of the DELETE FROM .. WHERE ... IN ( ... )  clause I >> > propose valid and SHOUL

Re: Should I be able to DELETE FROM ... WHERE .. IN ( ... ) with multiple a column key?

2009-05-27 Thread Simon J Mudd
per...@elem.com (Perrin Harkins) writes: > On Wed, May 27, 2009 at 6:43 AM, Simon J Mudd wrote: > > So is the format of the DELETE FROM .. WHERE ... IN ( ... )  clause I > > propose valid and SHOULD the optimiser recognise this and be expected > > to just find the 2 row

Re: Should I be able to DELETE FROM ... WHERE .. IN ( ... ) with multiple a column key?

2009-05-27 Thread Perrin Harkins
On Wed, May 27, 2009 at 6:43 AM, Simon J Mudd wrote: > So is the format of the DELETE FROM .. WHERE ... IN ( ... )  clause I > propose valid and SHOULD the optimiser recognise this and be expected > to just find the 2 rows by searching on the primary key? Not according to the d

Should I be able to DELETE FROM ... WHERE .. IN ( ... ) with multiple a column key?

2009-05-27 Thread Simon J Mudd
| transaction_history | range | PRIMARY,customer_id | PRIMARY | 16 | NULL |2 | Using WHERE | ++-+---+---+--+-+-+--+--+-+ 1 row IN set (0.02 sec) So is the format of the DELETE FROM .. WHERE ... IN ( ... ) clause I propose valid and SHOULD the

subquery for where in

2009-03-29 Thread Stephen Swift
Hi All, I am trying to find the top 5 ee_entry id's, and then return all rows matching any of the 5 ee_entry id's. I think I am close, but the following sql is currently only returning rows matching the first ee_entry in the group_concat. If I run the subquery separately and manually create the s

Re: Function call reult in a WHERE-IN clause

2008-12-17 Thread ceo
Perhaps pass in a "separator" string arg, default to '' and do: GROUP_CONCAT(DISTINCT h.hostid, separator) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Function call reult in a WHERE-IN clause

2008-12-17 Thread Cantwell, Bryan
I have a function that I built that returns a string that is really a comma separated list of values (below). I would like to use that returned value in an IN clause in sql. : select * from hosts where hostid in (getHosts(10014)); The function: CREATE FUNCTION getUserHosts(userID BIGINT(2

Re: order of items in a WHERE...IN clause

2008-10-24 Thread Moon's Father
See the usage of the function named field. On Mon, Jul 28, 2008 at 8:15 PM, Mr. Shawn H. Corey <[EMAIL PROTECTED]>wrote: > On Mon, 2008-07-28 at 07:32 -0400, Gary Josack wrote: > > Andrew Martin wrote: > > > Hello, > > > > > > Is it permissible to order a clause such that the search term is the >

Re: Impossible WHERE in explain

2008-09-02 Thread Krishna Chandra Prajapati
Thanks a lot. I got the answer. "Impossible where in explian" comes when the query doesn't make any sense to the mysql optimizer. Please visit the link below for more details. http://books.google.co.in/books?id=sgMvu2uZXlsC&pg=PA94&lpg=PA94&dq=impossible+where+n

RE: Impossible WHERE in explain

2008-09-01 Thread Martin Gainty
other than intended recipient. Sender does not necessarily endorse content contained within this transmission. > Date: Tue, 2 Sep 2008 02:05:00 +0530> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]> Subject: Re: Impossible WHERE in explain> CC: mysql@lists.mysql.com> > I have

Re: Impossible WHERE in explain

2008-09-01 Thread Jim Lyons
I just tried this. I got the same results *until* I inserted a record that met the criteria. SInce the values are for a primary key, EXPLAIN could see there was no such entry and so reported that. If you actually execute the command, you would not see an error, just no rows returned. EXPLAIN wa

Re: Impossible WHERE in explain

2008-09-01 Thread Krishna Chandra Prajapati
I have already tried. It's not working. On Tue, Sep 2, 2008 at 1:55 AM, Brent Baisley <[EMAIL PROTECTED]> wrote: > It might be because you you are comparing user_id to a string, when the > field type is a decimal. Drop the quotes around the user_id search value and > see if that works. > > Brent

Re: Impossible WHERE in explain

2008-09-01 Thread Brent Baisley
It might be because you you are comparing user_id to a string, when the field type is a decimal. Drop the quotes around the user_id search value and see if that works. Brent Baisley On Sep 1, 2008, at 3:59 PM, Krishna Chandra Prajapati wrote: Hi, In the query below explain gives 'Impossib

Impossible WHERE in explain

2008-09-01 Thread Krishna Chandra Prajapati
Hi, In the query below explain gives 'Impossible WHERE noticed after'. what does this mean. CREATE TABLE `user_cookie` ( `user_id` decimal(22,0) NOT NULL default '0', `param` varchar(128) NOT NULL default '', `value` varchar(128) default NULL, PRIMARY KEY (`user_id`,`param`), CONSTRA

Re: order of items in a WHERE...IN clause

2008-07-28 Thread Mr. Shawn H. Corey
On Mon, 2008-07-28 at 07:32 -0400, Gary Josack wrote: > Andrew Martin wrote: > > Hello, > > > > Is it permissible to order a clause such that the search term is the > > first item (in the clause)? > > > > standard: > > field1 IN (123, 654, 789) > > > > in question: > > 123 IN (field1, field2, field

Re: order of items in a WHERE...IN clause

2008-07-28 Thread Gary Josack
Andrew Martin wrote: Hello, Is it permissible to order a clause such that the search term is the first item (in the clause)? standard: field1 IN (123, 654, 789) in question: 123 IN (field1, field2, field3) I am interested to know if the optimizer treats this any differently if anybody can she

order of items in a WHERE...IN clause

2008-07-28 Thread Andrew Martin
Hello, Is it permissible to order a clause such that the search term is the first item (in the clause)? standard: field1 IN (123, 654, 789) in question: 123 IN (field1, field2, field3) I am interested to know if the optimizer treats this any differently if anybody can shed any light on it (exce

Re: WHERE .... IN

2008-07-24 Thread Johan Gant
Hi If you're searching for, effectively, %123% you probably can't use IN(). You could get away with wildcard patterns - if it's a heavily used field consider an index to increase performance. Hard to tell if this may be a FK of sorts, but if so you should use it as one which may involve normalisin

Re: WHERE .... IN

2008-07-24 Thread Mr. Shawn H. Corey
On Thu, 2008-07-24 at 09:34 +0530, Sivasakthi wrote: > How can we normalize the tables? could you explain bit more? > > > Thanks, > Siva > > Normalization is a complex subject. I suggest you search the web for tutorials. Try the search terms: RDBM normalization -- Just my 0.0002 milli

Re: WHERE .... IN

2008-07-23 Thread Sivasakthi
How about: WHERE ( field1 LIKE '123,%' OR field1 LIKE '*,123,%' OR field1 LIKE '%,123' OR field1 = '123' ) Note that this could that a long time on large tables. You'd be better off to normalize your tables ;) How can we normalize the tables? could you explain bit more? Thanks, Siva

Re: WHERE .... IN

2008-07-23 Thread Mr. Shawn H. Corey
On Wed, 2008-07-23 at 17:05 +0300, Ali Deniz EREN wrote: > Hi all, > > I have a problem as below: > > A text field -Lets call it 'field1'- contains datas seperated by > commas(,) like this (123,5764,8795,9364,11,232,. and go on) And so > my lines like these: > > id title filed1 > -

Re: WHERE .... IN

2008-07-23 Thread Peter Brawley
>A text field -Lets call it 'field1'- contains datas seperated by commas(,) > like this (123,5764,8795,9364,11,232,. The solution is to normalise the data. PB Ali Deniz EREN wrote: Hi all, I have a problem as below: A text field -Lets call it 'field1'- contains datas seperated by comma

WHERE .... IN

2008-07-23 Thread Ali Deniz EREN
Hi all, I have a problem as below: A text field -Lets call it 'field1'- contains datas seperated by commas(,) like this (123,5764,8795,9364,11,232,. and go on) And so my lines like these: id title filed1 - 1 title1

RE: Ordering rows whit a select from where in ( exp )

2005-04-25 Thread mathias fatene
n [mailto:[EMAIL PROTECTED] Sent: lundi 25 avril 2005 10:06 To: mysql@lists.mysql.com Subject: Ordering rows whit a select from where in ( exp ) Hi everyone, Here is my issue: I have this Query : SELECT field_name FROM meta WHERE id IN ('13','11',

Re: Ordering rows whit a select from where in ( exp )

2005-04-25 Thread =?ISO-8859-1?Q?Johan_H=F6=F6k?=
Hi Adrian, you can do SELECT field_name FROM meta WHERE id IN ('13','11','7','8','9','10','12') ORDER BY FIELD(id,'13','11','7','8','9','10','12') /Johan Adrian wrote: Hi everyone, Here is my issue: I have this Query : SELECT field_name FROM meta WHERE id IN

Ordering rows whit a select from where in ( exp )

2005-04-25 Thread Adrian
Hi everyone, Here is my issue: I have this Query : SELECT field_name FROM meta WHERE id IN ('13','11','7','8','9','10','12') I want the rows to be display in the same order as the in list of ids.Any ideas? Should I use order by? Whit witch optio

Re: UNION (was: WHERE ... IN () )

2005-01-31 Thread Jigal van Hemert
> Here is my solution: > (SELECT ID, referentie, postcode, gemeente, > kadastrale_opp,prijs_zichtbaar, verkoopprijs, status, adres, '' AS > hoofdtype FROM gronden WHERE status = 'te koop' ) UNION (SELECT ID, > referentie, postcode, gemeente, kadastrale_opp, prijs_zichtbaar, > verkoopprijs, doel AS

Re: WHERE ... IN ()

2005-01-31 Thread Stijn Verholen
Jay, thx for your speedy reply. MySQL does indeed know the "WHERE IN" syntax (bad coding on my part). I have another question. There are two tables in the db from which I want to gather information. These tables are identical, except for two fields that have different names, the same

RE: WHERE ... IN ()

2005-01-31 Thread Jay Blanchard
[snip] ANSI SQL has the WHERE key IN (value1, value2, ...) MySQL doesn't seem to support this. Is this a faulty assumption, or am i stuck with WHERE key = value1 OR key = value2 ... [/snip] It is a faulty assumption, see http://dev.mysql.com/doc/mysql/en/comparison-operators.html SELECT stuff F

WHERE ... IN ()

2005-01-31 Thread Stijn Verholen
Greetings, list ! ANSI SQL has the WHERE key IN (value1, value2, ...) MySQL doesn't seem to support this. Is this a faulty assumption, or am i stuck with WHERE key = value1 OR key = value2 ... TIA, Stijn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:

RE: UPDATE...WHERE ... IN (SELECT...)

2004-06-09 Thread Laercio Xisto Braga Cavalcanti
Hi Markus, You cannot use sub-query in mysql 3.23.49 Regards, Laercio Cavalcanti. -Original Message- From: Markus Källander [mailto:[EMAIL PROTECTED] Sent: quarta-feira, 9 de junho de 2004 13:25 To: [EMAIL PROTECTED] Subject: UPDATE...WHERE ... IN (SELECT...) Hi all, Can someone

Re: UPDATE...WHERE ... IN (SELECT...)

2004-06-09 Thread Josh Trutwin
On Wed, 9 Jun 2004 18:25:11 +0200 Markus Källander <[EMAIL PROTECTED]> wrote: > Hi all, > > Can someone tell me what is wrong with this statement? > > UPDATE nummer SET gold = '1' WHERE anr IN (SELECT no FROM gull); > > I use MySQL 3.23.49. ^^^ 4.1 or higher is required f

RE: UPDATE...WHERE ... IN (SELECT...)

2004-06-09 Thread Young, Michael
> -Original Message- > From: Markus Källander > [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 09, 2004 10:25 AM > To: [EMAIL PROTECTED] > Subject: UPDATE...WHERE ... IN (SELECT...) > > > Hi all, > > Can someone tell me what is wrong with this st

RE: UPDATE...WHERE ... IN (SELECT...)

2004-06-09 Thread Victor Pendleton
Sub-select not supported in version you are using. -Original Message- From: Markus Källander To: [EMAIL PROTECTED] Sent: 6/9/04 11:25 AM Subject: UPDATE...WHERE ... IN (SELECT...) Hi all, Can someone tell me what is wrong with this statement? UPDATE nummer SET gold = '1'

UPDATE...WHERE ... IN (SELECT...)

2004-06-09 Thread Markus Källander
Hi all, Can someone tell me what is wrong with this statement? UPDATE nummer SET gold = '1' WHERE anr IN (SELECT no FROM gull); I use MySQL 3.23.49. Thanks Markus Källander

Re: WHERE IN performance

2003-10-30 Thread Matt W
dummy values). If you're using MySQL 3.23, I've noticed that the query parser seems much, much faster in 4.0. Matt - Original Message - From: "Knepley, Jim" Sent: Thursday, October 30, 2003 4:48 PM Subject: WHERE IN performance Is it anyone elses experience that queries

Re: WHERE IN performance

2003-10-30 Thread bluejack
On Thu, 30 Oct 2003 15:48:05 -0700, Knepley, Jim <[EMAIL PROTECTED]> wrote: Is it anyone elses experience that queries with large IN stanzas in a WHERE clause don't scale very well? It seems like it's beyond a linear performance hit when I have a large number (thousands) of tokens in an IN clause,

WHERE IN performance

2003-10-30 Thread Knepley, Jim
Is it anyone elses experience that queries with large IN stanzas in a WHERE clause don't scale very well? It seems like it's beyond a linear performance hit when I have a large number (thousands) of tokens in an IN clause, even when the matching field is indexed. Is this something that buffer twe

Re: WHERE IN SYNTAX

2002-12-03 Thread Peter Abilla
"a set which contains as an element > the set itself" > > WHERE fooId IN (fooId) > > Adolfo > >> -Original Message- >> From: Peter Abilla [mailto:[EMAIL PROTECTED]] >> Sent: Monday, December 02, 2002 1:43 PM >> To: [EMAIL PROTECTED] >> S

RE: WHERE IN SYNTAX

2002-12-02 Thread Adolfo Bello
002 1:43 PM > To: [EMAIL PROTECTED] > Subject: sql:WHERE IN SYNTAX > > > Question about SQL "WHERE IN" syntax: > > I know that something like this is fine to do: > > (1) > SELECT foo > FROM bar > WHERE fooID in ('1','2') > &

Re: WHERE IN ( MAX ) in MySQL

2001-09-02 Thread Benjamin Pflugmann
Hi. This is mentioned in the fine manual: http://www.mysql.com/doc/e/x/example-Maximum-column-group-row.html Bye, Benjamin. On Fri, Aug 31, 2001 at 01:46:43PM +0200, [EMAIL PROTECTED] wrote: [...] > Normally I would go about like this: > SELECT currency_rate.currency_id, currency_dat

Re: WHERE IN ( MAX ) in MySQL

2001-08-31 Thread Chris Johnson
I think you will you have to do it in 2 steps using a temporary table. This is one of MySQL's biggest weak points. ..chris - Original Message - From: "Mattias Jiderhamn" <[EMAIL PROTECTED]> I have a table CREATE TABLE currency_rate ( currency_id VARCHAR(3), currency_date DA

WHERE IN ( MAX ) in MySQL

2001-08-31 Thread Mattias Jiderhamn
I have a table CREATE TABLE currency_rate ( currency_id VARCHAR(3), currency_date DATE, currency_rate NUMERIC(16,8), PRIMARY KEY (currency_id, currency_date) ); and want to list the latest registered rates of all currencies. Normally I would go about like this: SELECT curr