Re: Query Question

2006-08-14 Thread nigel wood
Michael DePhillips wrote: Hi Dan, Thanks for the prompt reply, As I described it yes, you are correct, however, the id may not always be one(1) value away. So the number one needs, somehow, to be replaced with a way to get the "next largest value " and the "previous less than" value. Sorr

Re: Query Question

2006-08-14 Thread Michael DePhillips
Hi Dan, Thanks for the prompt reply, As I described it yes, you are correct, however, the id may not always be one(1) value away. So the number one needs, somehow, to be replaced with a way to get the "next largest value " and the "previous less than" value. Sorry for the lack of precision

Re: Query Question

2006-08-14 Thread nigel wood
Michael DePhillips wrote: Hi, Does anyone have a clever way of returning; a requested value with one value less than that value, and one value greater than that value with one query. For example T1 contains ID 1234 1235 1236 1238 Assuming the id's are consecutive. You want surounding

Re: Query Question

2006-08-14 Thread Dan Julson
Michael, I would think this is what you want. Select ID from T1 where ID BETWEEN ( - 1) and ( + 1) If you want distinct values, place the distinct keyword in front of ID (i.e. Select DISTINCT ID... This should do it for you. -Dan Hi, Does anyone have a clever way of returning; a requested

RE: query needed

2006-08-13 Thread Peter Lauri
Not until we know the logic behind the "code" and how the calculations should be done. -Original Message- From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 1:03 PM To: Peter Lauri; mysql@lists.mysql.com Subject: Re: query needed if it is stat

Re: query needed

2006-08-13 Thread VenuGopal Papasani
if it is static then it works fine.but we have lots of codes in a table which should be done similar operation.instead varifying staticly with c1,c2 can we make dynamic. On 8/14/06, Peter Lauri <[EMAIL PROTECTED]> wrote: SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4'

RE: query needed

2006-08-13 Thread Peter Lauri
SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4', code, IF(code='c5', code, 0))) FROM datavalue; -Original Message- From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 11:26 AM To: mysql@lists.mysql.com Subject: query needed Hi, i

Re: query needed

2006-08-13 Thread VenuGopal Papasani
Once again i send the table data: Code Period Value c1 2004 22 c1 2005 10 c2 2005 15 c3 2005 20 c4 2005 15 c5 2005 5 c6 2005 30 c7 2005

Re: query needed

2006-08-13 Thread Chris
VenuGopal Papasani wrote: Hi, i got a table datavalue as follows code period value c1 20051 c2 20052 c32006 3

RE: query logging is making me mental!

2006-08-08 Thread Josh Milane
I figured it out. Thanks for listening. I maybe just needed to vent. -Original Message- From: Josh Milane [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 08, 2006 12:46 PM To: mysql@lists.mysql.com Subject: query logging is making me mental! Hello Everyone, I am hoping that someone

Re: Query two databases

2006-08-08 Thread brent
Mazur Worden, Kathy wrote: which column(s) isn't found? Would it happen to be any of the columns you're using a function on? I ask because aliasing those might help. I can confirm that passing the full db name will work with ASP through a recordset. I've set them up like this: Set objConn

Re: query logging is making me mental!

2006-08-08 Thread Daniel da Veiga
On 8/8/06, Josh Milane <[EMAIL PROTECTED]> wrote: I installed MYSQL 5 along with PHP and apache 2 as part of the XAMPP stack put out by ApacheFriends. I am putting together a few CMS sites and think the product is great. I don't. IMHO anything that hides stuff you SHOULD know to use the softwa

RE: Query Help for Loosely Couple Properties

2006-08-08 Thread Robert DiFalco
27; OR (NST.VAL = 'Fred' AND NSV.REF_ID IS NULL) ) How do I generally simplify this? R. -Original Message- From: Robert DiFalco [mailto:[EMAIL PROTECTED] Sent: Friday, August 04, 2006 4:12 PM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: RE: Query Help for Loosely Coupl

RE: Query two databases

2006-08-08 Thread Mazur Worden, Kathy
To: Mazur Worden, Kathy Cc: mysql@lists.mysql.com Subject: Re: Query two databases Mazur Worden, Kathy wrote: I've had success using the fully qualified db, table and column name in a single query like yours below.

Re: Query two databases

2006-08-08 Thread brent
Mazur Worden, Kathy wrote: I've had success using the fully qualified db, table and column name in a single query like yours below. Have you tried sending strSQLCombo through either strConnProd or strConnSales already? K. Mazur Worden Kathy, Just tried referencing one and got the "Item cann

RE: Query two databases

2006-08-08 Thread Mazur Worden, Kathy
I've had success using the fully qualified db, table and column name in a single query like yours below. Have you tried sending strSQLCombo through either strConnProd or strConnSales already? K. Mazur Worden > -Original Message- > From: brent [mailto:[EMAIL PROTECTED] > Sent: Monday, A

Re: Query

2006-08-04 Thread chris smith
On 8/5/06, Karl Larsen <[EMAIL PROTECTED]> wrote: I am using Linux called Fedora Core 4. I had no problem getting mysql 4 working here and liked it a lot. But when I discovered 4 doesn't have VIEW but 5 does I have tried several RPM sets of 5 that fail for basic reasons. The reasons are the w

RE: Query Help for Loosely Couple Properties

2006-08-04 Thread Robert DiFalco
e- From: Jay Pipes [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 02, 2006 9:37 AM To: Robert DiFalco Cc: mysql@lists.mysql.com Subject: Re: Query Help for Loosely Couple Properties On Tue, 2006-08-01 at 16:23 -0700, Robert DiFalco wrote: > The question is, how do I query this? Say I w

Re: Query problem

2006-08-03 Thread obed
On 8/3/06, André Hänsel <[EMAIL PROTECTED]> wrote: Hi Dan, hi Obed, of course I have no specific username, I want the last 5 downloads of each distinct username in the table. :) i was thinking a lot... and i can't find the solution but maybe yo can do somthing like this select user,downl

Re: Query problem

2006-08-03 Thread Miles Thompson
At 03:08 PM 8/3/2006, André Hänsel wrote: Hi, I have a table logging downloads (time, username, download). Now I'd like to have the last 5 downloads per user. Can someone tell me a solution (or what to search for)? Regards, André -- MySQL General Mailing List For list archives: http://list

Re: Query problem

2006-08-03 Thread Dan Buettner
For a specific username: SELECT username, time, download FROM table WHERE username = 'someusername' ORDER BY time DESC LIMIT 5 Dan On 8/3/06, André Hänsel <[EMAIL PROTECTED]> wrote: Hi, I have a table logging downloads (time, username, download). Now I'd like to have the last 5 downloads per

Re: Query problem

2006-08-03 Thread obed
On 8/3/06, André Hänsel <[EMAIL PROTECTED]> wrote: Hi, I have a table logging downloads (time, username, download). Now I'd like to have the last 5 downloads per user. Can someone tell me a solution (or what to search for)? SELECT download FROM table WHERE username='user' ORDER BY time DES

Re: Query Help for Loosely Couple Properties

2006-08-02 Thread Jay Pipes
On Tue, 2006-08-01 at 16:23 -0700, Robert DiFalco wrote: > The question is, how do I query this? Say I want all records from table > T whose COLOR property value is ORANGE. > > The only thing I can come up with (and I'm no SQL expert and this looks > wrong to me) is the following: > > SELECT * >

Re: query cache about the federated engine

2006-08-02 Thread Michael Loftis
--On August 2, 2006 5:25:51 PM +0800 wangxu <[EMAIL PROTECTED]> wrote: I have a problem about the performance of federated engine. The mysql5.0 reference manual says that the FEDERATED tables do not work with the query cache, aren't they? How about the query cache used by the federated eng

RE: Query Help for Loosely Couple Properties

2006-08-02 Thread Robert DiFalco
They are user defined properties. -Original Message- From: Jay Pipes [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 01, 2006 8:11 PM To: Robert DiFalco Cc: mysql@lists.mysql.com Subject: Re: Query Help for Loosely Couple Properties On Tue, 2006-08-01 at 16:23 -0700, Robert DiFalco

Re: Query Help for Loosely Couple Properties

2006-08-01 Thread Jay Pipes
On Tue, 2006-08-01 at 16:23 -0700, Robert DiFalco wrote: > I have a table that contains properties that can be associated with any > table whose primary key is a LONG. Lets say that there is just one kind > of property. The table looks something like this: > > TABLE StringVal > REF_ID B

Re: Query multiple tables

2006-07-02 Thread Peter Brawley
>What query do I need to get >AccommodationName and what attractions it has from AccommodationAttractions SELECT ac.accommodationname, at.attractionname aa.AccomodationAttraction FROM accommodationattractions AS aa INNER JOIN accommodations AS ac USING (accommodationid) INNER JOIN attractio

Re: Query Speed

2006-06-28 Thread Jay Pipes
ouping.State = advisor_counts.State AND primary_grouping.Sub = advisor_counts.Sub AND primary_grouping.ChapterType = advisor_counts.ChapterType; - Original Message - From: "Jay Pipes" <[EMAIL PROTECTED]> To: "Jesse" <[EMAIL PROTECTED]> Cc: "mysql"

Re: Query Speed

2006-06-28 Thread Jesse
timing. However, if I can get your more efficient query working, I would like to. Any ideas why it's not working? Thanks, Jesse - Original Message - From: "Jay Pipes" <[EMAIL PROTECTED]> To: "Jesse" <[EMAIL PROTECTED]> Cc: "mysql" Sent

Re: Query Speed

2006-06-27 Thread Jay Pipes
Jesse wrote: I worked with the query for a while, trying equi-joins instead of JOINs, and variuos other things. I found that the queries that I was using to represent the TotMem & TotAdv columns was what was closing things down. I finally ended up using a sub-query to solve the problem. I ga

Re: Query Speed

2006-06-27 Thread Jesse
pterType) AS sq ORDER BY State, Sub, ChapterType Anyway, thanks for your help. Jesse - Original Message - From: "Dan Buettner" <[EMAIL PROTECTED]> Cc: "Jesse" <[EMAIL PROTECTED]>; "mysql" Sent: Monday, June 26, 2006 8:18 PM Subject: Re: Query S

Re: QUERY

2006-06-27 Thread Asif Lodhi
Hi John, On 6/24/06, John Hicks <[EMAIL PROTECTED]> wrote: Karl Larsen wrote: > ..I was glancing through the mamouth > MySQL reference manual ... I worked on an Oracle-9i development project around two years back. If I recall correct

Re: Query Speed

2006-06-26 Thread Dan Buettner
, 'PRIMARY,IX_Schools1', 'IX_Schools1', '18', 'bpa.S.State,bpa.S.Sub', 65, 'Using where' 2, 'DEPENDENT SUBQUERY', 'C1', 'ref', 'PRIMARY,IX_Chapters_1,IX_Chapters_2', 'IX_Chapters_1', '

Re: Query Speed

2006-06-26 Thread Dan Buettner
27;, 'S1', 'ref', 'PRIMARY,IX_Schools1', 'IX_Schools1', '18', 'bpa.S.State,bpa.S.Sub', 65, 'Using where' 2, 'DEPENDENT SUBQUERY', 'C1', 'ref', 'PRIMARY,IX_Chapters_1,IX_Chapters_2', '

Re: Query Speed

2006-06-26 Thread Dan Buettner
Jesse, can you post table structures ( SHOW CREATE TABLE tablename ) and the output you get from EXPLAIN followed by the query below? Also what version of MySQL you're on, and high level details of the hardware (RAM, disks, processors, OS). That will all be helpful in trying to help you out he

Re: Query Speed

2006-06-26 Thread Jesse
From: "Price, Randall" <[EMAIL PROTECTED]> To: "Jesse" <[EMAIL PROTECTED]>; "MySQL List" Sent: Monday, June 26, 2006 4:47 PM Subject: RE: Query Speed Hi Jesse, I am not 100% sure cause I have only been using MySQL for ~6 months but I do read this mailing li

RE: Query Speed

2006-06-26 Thread Price, Randall
Hi Jesse, I am not 100% sure cause I have only been using MySQL for ~6 months but I do read this mailing list everyday and have learned a lot. I believe that InnoDB tables to not maintain a count(*) for the tables so it has to physically count the rows. I believe MyISAM tables do maintain that c

Re: query slow

2006-06-25 Thread luiz Rafael
Hello friends Id like to thanks all friends that helped with this question Regards Luiz -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: QUERY

2006-06-24 Thread Karl Larsen
John Hicks wrote: Karl Larsen wrote: I and a friend have written SQL to big Oracle DB but not much to MySQL on our own computers. I find that there is a QUERY in the list for MySQL but it does nothing much. Also I was glancing through the mamouth MySQL reference manual and saw there are a b

Re: QUERY

2006-06-24 Thread John Hicks
Karl Larsen wrote: I and a friend have written SQL to big Oracle DB but not much to MySQL on our own computers. I find that there is a QUERY in the list for MySQL but it does nothing much. Also I was glancing through the mamouth MySQL reference manual and saw there are a bunch of tools that

Re: query slow

2006-06-21 Thread Eugene Kosov
luiz Rafael wrote: SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) OR (1999 = YEAR(`emissao`) AND 12 < MONTH(`emissao`)) ORDER BY emissao ASC Are you sure this is what you really want? MONTH() is never greater than 12, so your query is equal to: SELECT * FROM `sav00_sav

Re: query slow

2006-06-21 Thread Eugene Kosov
Jay Pipes wrote: SELECT * FROM `sav00_sava0400_dbf` emissao BETWEEN '2000-01-01' AND '2000-12-31' UNION ALL SELECT * FROM `sav00_sava0400_dbf` emissao BETWEEN '1999-12-01' AND '1999-12-31' Why not: SELECT * FROM `sav00_sava0400_dbf` emissao BETWEEN '1999-12-01' AND '2000-12-31' ?? ;) -

Re: query slow

2006-06-21 Thread luiz Rafael
Hi Jay Thanks for the help Regards Luiz -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: query slow

2006-06-21 Thread Jay Pipes
luiz Rafael wrote: Dear friends is their any way to optimize this query bellow, it take +- 2minutes do complete, i think it becouse their no index by the emissao field SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) OR (1999 = YEAR(`emissao`) AND 12 < MONTH(`emissao`)) O

Re: Query question: select * from table where id in (1,2,3) order by date uses FILESORT

2006-06-20 Thread Dan Buettner
I agree with Brent on what MySQL is doing ... are you seeing poor performance with this query? If so, you might evaluate whether adding an index on your 'post_date' column improves things, as MySQL may be able to sort and thus LIMIT more quickly (using index in RAM rather than reading off disk

Re: Query question: select * from table where id in (1,2,3) order by date uses FILESORT

2006-06-20 Thread Brent Baisley
MySQL is doing a file sort on the query result. It's not sorting the entire table and it's not sorting the 40 record limit you specified. It's sorting the WHERE id IN... result. After the sort, then it will return just the first 40 records. You can throw and EXPLAIN in front of the query to see

Re: Query performance.

2006-06-07 Thread Eugene Kosov
Thanks a lot!! :D You were right. There was a bug. Upgrading to mysql 4.1.20 solved my problem. Daniel da Veiga wrote: Check http://bugs.mysql.com/bug.php?id=12915 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAI

Re: Query performance.

2006-06-06 Thread Daniel da Veiga
On 6/6/06, Eugene Kosov <[EMAIL PROTECTED]> wrote: Hi, List! I'm a little bit confused with (IMHO) poor query performance. I have a table with 1'000'000 records. Table consists of 2 service fields and a number of data fields. Service fields are status and processor_id (added for concurrent que

Re: Query problem

2006-05-30 Thread John Meyer
Rhino wrote: - Original Message - From: "John Meyer" <[EMAIL PROTECTED]> To: "List: MySQL" Sent: Tuesday, May 30, 2006 5:09 PM Subject: Query problem Setup TITLES: TITLE_ID AUTHORS: AUTHOR_ID TITLE_AUTHOR: (TITLE_ID,AUTHOR_ID) Problem: Given a title, I need to find all the aut

Re: Query problem

2006-05-30 Thread Rhino
- Original Message - From: "John Meyer" <[EMAIL PROTECTED]> To: "List: MySQL" Sent: Tuesday, May 30, 2006 5:09 PM Subject: Query problem Setup TITLES: TITLE_ID AUTHORS: AUTHOR_ID TITLE_AUTHOR: (TITLE_ID,AUTHOR_ID) Problem: Given a title, I need to find all the authors who are

Re: Query to slow after inserting another table

2006-05-27 Thread Merlin
Hi, thank you for this hint. That worked excellent! Now the overall query time is about 0.1 s on average. Best regards, Merlin On Sat, 27 May 2006 02:14:34 -0700, "Merlin" <[EMAIL PROTECTED]> said: > Well this is exactly the problem. The OR statement. Do you think there > is > another way aroun

Re: Query to slow after inserting another table

2006-05-27 Thread Merlin
Well this is exactly the problem. The OR statement. Do you think there is another way around the tmp table. I did not make the best experiances with tmp tables. regards, merlin On Sat, 27 May 2006 00:26:09 -0500, "mos" <[EMAIL PROTECTED]> said: > Merlin, > Lose the "OR" part of the Where

Re: Query to slow after inserting another table

2006-05-26 Thread mos
Merlin, Lose the "OR" part of the Where clause and it should speed up. If so, that's what you have to work on. You could execute 2 queries, where each one writes the results to a temporary memory table and display that table instead. Mike -- MySQL General Mailing List For list archives: ht

Re: Query problem: UNION in subquery

2006-05-24 Thread Luke
> To: "'Luke'" <[EMAIL PROTECTED]>; Sent: Wednesday, May 24, 2006 2:16 AM Subject: RE: Query problem: UNION in subquery Hi Luke.. Try this SELECT ObjectId FROM (SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId FROM form15 f15 WHER

RE: Query problem: UNION in subquery

2006-05-23 Thread Neeraj
Hi Luke.. Try this SELECT ObjectId FROM (SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId FROM form15 f15 WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6') UNION SELECT f15.Form15SampleTube6RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId

Re: query help-multiple joins

2006-05-23 Thread mel list_php
Perfect! I tried aliasing the field names but didn't think about the table, and was just stuck looking at that query without any idea... Thanks a lot for your help. melanie From: Johan Höök <[EMAIL PROTECTED]> To: mel list_php <[EMAIL PROTECTED]> CC: mysql@lists.mysq

Re: query help-multiple joins

2006-05-23 Thread Johan Höök
Hi, I guess you should be able to do something like: SELECT t1.term_id, t1.name, r.type_id, t2.term_id, t2.name FROM term t1 LEFT JOIN relationTerm r ON r.term_id1 = t1.term_id LEFT JOIN term t2 ON r.term_id2 = t2.term_id /Johan mel list_php skrev: Hi! I'm stuck with a join query 2 tables

Re: query of a query?

2006-05-05 Thread Bing Du
> Not necessarily. I would think the CREATE SELECT statement would be > the closest equivalent. > > http://dev.mysql.com/doc/refman/4.1/en/create-table.html > Thanks much for the reply, John. That surely would help with our future applications. But this time, we only have read access to the

Re: query of a query?

2006-05-04 Thread John Hicks
Bing Du wrote: The following are Cold Fusion code. It's interesting that previously defined queries can be used as 'tables' to pull data from. === SELECT db_entry_num, title FROM account_info SELECT projectID

Re: Query Help

2006-05-01 Thread Robert Gehrig
Thanks that got it. Robert Gehrig Webmaster at www.gdbarri.com e-mail: [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: Query Help

2006-05-01 Thread Gabriel PREDA
SELECT id, count(*) AS cnt FROM `table_name` GROUP BY id ORDER BY cnt DESC [ LIMIT 1 ] -- Gabriel PREDA Senior Web Developer

Re: Query results for text with á é ö ã etc

2006-04-18 Thread Philippe Poelvoorde
2006/4/18, Pedro mpa <[EMAIL PROTECTED]>: > Greetings. > > I have Text fields in some tables which contain text in Portuguese with > accent characters like á, à, é, í, ú, ü, ó, ö, ç, etc. > > When I query like: > > SELECT text_column > FROM table > WHERE text_column LIKE '%maçã%' > [ or ] > WHERE t

Re: Query help with count and join on same table I think

2006-04-10 Thread Frank
2wsxdr5 wrote: > I have a table of people. Some of the people in this table are > related. You can find out who is related by comparing a familyID > number. I have a query to select a certain group of people from the > table and I want to also select anyone who is related to them, even > though

Re: Query Optimization Question

2006-03-14 Thread Michael Stassen
[EMAIL PROTECTED] wrote: Yes, a ranged query should respond faster than a negation. In some cases you can seriously improve query performance for a negation query if you split it into two range queries unioned together. Here is a pseudo example: This query should be slow due to the table scan

Re: Query Optimization Question

2006-03-13 Thread Michael Stassen
Robert DiFalco wrote: > In a previous database engine I was using an IN was more optimal than a > <>. So, for example: > > SELECT * FROM table WHERE table.type IN (1,2,3); > > Where the possible values of type are 0-3, was appreciably faster than: > > SELECT * FROM table WHERE table.type <

RE: Query Optimization Question

2006-03-13 Thread Robert DiFalco
ql.com Subject: RE: Query Optimization Question Yes, a ranged query should respond faster than a negation. In some cases you can seriously improve query performance for a negation query if you split it into two range queries unioned together. Here is a pseudo example: This query should be slow

RE: Query Optimization Question

2006-03-13 Thread SGreen
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Monday, March 13, 2006 6:37 AM > To: Robert DiFalco > Cc: mysql@lists.mysql.com > Subject: Re: Query Optimization Question > > > > > "Robert DiFalco" <[EMAIL PROTECTED]>

RE: Query Optimization Question

2006-03-13 Thread Robert DiFalco
Shawn, Any performance gains for specifying "type > 0" than "type <> 0" ? R. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, March 13, 2006 6:37 AM To: Robert DiFalco Cc: mysql@lists.mysql.com Subject: Re

Re: Query Optimization Question

2006-03-13 Thread SGreen
"Robert DiFalco" <[EMAIL PROTECTED]> wrote on 03/11/2006 12:43:43 PM: > In a previous database engine I was using an IN was more optimal than a > <>. So, for example: > > SELECT * FROM table WHERE table.type IN (1,2,3); > > Where the possible values of type are 0-3, was appreciably faster th

Re: Query help

2006-03-12 Thread Peter Brawley
OKAN ARI wrote: I have 3 tables Table 1: user(id, name, surname) Table 2: crime(id, detail) Table 3: user_crime(id, user_id, crime_id) Table 1 1, OKAN, ARI Table 2 1, "detail 1" 2, "Detail 2" Table 3 1, 1, 1 1, 1, 2 So user 1 takes 2 crime from crime table... I want to receive info with 1 qu

Re: query problem

2006-03-12 Thread Don Read
On Wed, 8 Mar 2006 10:12:22 - <[EMAIL PROTECTED]> wrote: > but I have two other filters which may or may not be chosen. (area, and > interest). > > $query = "SELECT * FROM $table_name WHERE sname LIKE '$search_string%' AND > area='area' AND interest='interest' ORDER BY fname $type"; > >

Re: Query Optimization Question

2006-03-11 Thread Mladen Adamovic
Robert DiFalco wrote: In a previous database engine I was using an IN was more optimal than a <>. So, for example: SELECT * FROM table WHERE table.type IN (1,2,3); Where the possible values of type are 0-3, was appreciably faster than: SELECT * FROM table WHERE table.type <> 0; I

Re: query problem

2006-03-08 Thread Peter Brawley
[EMAIL PROTECTED] wrote: I am fairly new to sql and am now getting into the area of slightly more complex queries. At present my query is $query = "SELECT * FROM $table_name WHERE sname LIKE '$search_string%' ORDER BY fname $type"; but I have two other filters which may or may not be chosen

Re: query problem

2006-03-08 Thread Daniel da Veiga
On 3/8/06, Adrian Bruce <[EMAIL PROTECTED]> wrote: > one solution (may not be the best but would work) would be to use 'like' > instead of '=' and then put wildcards %%$var % around the variable so > that if it is not there then it wount effect the query. > Yeah, I use this kind of "trick" for SEL

Re: query problem

2006-03-08 Thread Adrian Bruce
one solution (may not be the best but would work) would be to use 'like' instead of '=' and then put wildcards %%$var % around the variable so that if it is not there then it wount effect the query. Ade [EMAIL PROTECTED] wrote: I am fairly new to sql and am now getting into the area of slight

Re: Query returns to many results

2006-02-24 Thread Schalk
Peter Brawley wrote: />Now this query is run over two tables and the ab_members table contains >around 302 rows. Around 1/3 of these will be where cup=kids. However, >when this query is run it returns 20,700 results / That's because your ... FROM ab_leader_board ablb, ab_members abm calls for

Re: Query returns to many results

2006-02-23 Thread Peter Brawley
>Now this query is run over two tables and the ab_members table contains >around 302 rows. Around 1/3 of these will be where cup=kids. However, >when this query is run it returns 20,700 results That's because your ... FROM ab_leader_board ablb, ab_members abm calls for a cross join--it a

Re: query help?

2006-02-23 Thread Richard Reina
Actually I am looking for duplicates (vedor_no, date), but I think I can hopefully adapt the solution you have given me. [EMAIL PROTECTED] wrote: If you are looking just for duplicate (ID,vendort_no) combinations, this will find them: SELECT ID, vendor_no, count(1) as dupes FROM table_name

Re: query help?

2006-02-23 Thread SGreen
If you are looking just for duplicate (ID,vendort_no) combinations, this will find them: SELECT ID, vendor_no, count(1) as dupes FROM table_name_here GROUP BY ID, vendor_no HAVING dupes >1; Shawn Green Database Administrator Unimin Corporation - Spruce Pine Richard Reina <[EMAIL PROTECTED]> wr

Re: query help?

2006-02-23 Thread Richard Reina
I's so sorry. You are very correct. The sample data is bad. ID should be unique. Here it is corrected. |ID| vendor_no| date| |2354 | 578 | "2005-12-23"| |2355 | 334 | "2005-12-24"| |2356 | 339 | "2005-12-26"| |2357 | 339

RE: query help?

2006-02-23 Thread Andy Eastham
Richard, If you mean with _both_ the same id _and_ vendor id, try this: Select id, vendor_id, count(*) from tablename group by id, vendor_id; If you just want separate counts for id and vendor_id, use: Select id, count(*) from tablename group by id; Select vendor_id, count(*) from tablename gr

Re: query help?

2006-02-23 Thread cnelson
> I am a novice when it come to queries such as this and was hoping > someone could help me write a query that tells me how many records > have the same ID and vendor number. > > |ID| vendor_no| date| > |2354 | 578 | "2005-12-23"| > |2355 | 334 |

Re: Query returns to many results

2006-02-23 Thread Martijn Tonies
> Again, I implore all SQL coders to use the explicit JOIN syntax on all > platforms that support it (Oracle being a well-known exception). It makes Oracle supports the ANSI JOIN syntax from v9 and up. > Shawn Green As for the rest, I fully agree. Martijn Tonies Database Workbench - development

Re: Query returns to many results

2006-02-23 Thread SGreen
Schalk <[EMAIL PROTECTED]> wrote on 02/23/2006 08:55:01 AM: > George Law wrote: > > Schalk , > > > > You need to specify the unifying column between your ablb and abm tables. > > > > ie - in your where, "and ablb.id=abm.id" > > > > Once you get this so it returns expected results, you can run the

Re: Query returns to many results

2006-02-23 Thread Schalk
George Law wrote: Schalk , You need to specify the unifying column between your ablb and abm tables. ie - in your where, "and ablb.id=abm.id" Once you get this so it returns expected results, you can run the query, prefaced with "explain" and it will give you an idea on the way mysql is runni

Re: Query returns to many results

2006-02-23 Thread George Law
Schalk , You need to specify the unifying column between your ablb and abm tables. ie - in your where, "and ablb.id=abm.id" Once you get this so it returns expected results, you can run the query, prefaced with "explain" and it will give you an idea on the way mysql is running the query. Thi

Re: query problem

2006-02-09 Thread Conor McTernan
Sheeri, Thanks for the help. I tried your sample queries, but they dont really return what I'm looking for. I think I've found a solution though. Given the contents of a case, I'm looking for a unique case id, basicially I want to search for a case if it exists once I've decided the configuration

Re: query problem

2006-02-09 Thread sheeri kritzer
You originally mention your UNION "doesn't work" but you did not specify the query. This is a simple or query, or union. You can do either: select CaseType_idCaseType,Sizes_idsizes,qty from CaseType_has_Sizes where (qty=1 and Sizes_idsizes=2) or (qty=1 and Sizes_idsizes=4); or select CaseType_

Re: query problem

2006-02-08 Thread Conor McTernan
Sheeri, The table I'm searching on has a composite primary key since it's mapping an N:M relationship between Cases and Sizes. Here's the create statement for the table I'm searching on: DROP TABLE IF EXISTS `CaseType_has_Sizes`; CREATE TABLE `CaseType_has_Sizes` ( `CaseType_idCaseType` int(10

Re: query problem

2006-02-08 Thread sheeri kritzer
Hi Conor, The table you showed us has 2 primary keys, which is not possible. Can you do a SHOW CREATE TABLE on *each* table? -Sheeri On 2/8/06, Conor McTernan <[EMAIL PROTECTED]> wrote: > Hello, I'm having a hell of a time figuring this query out, maybe someone > can point me in the right direc

Re: Query Speed

2006-02-08 Thread سيد هادی راستگوی حقی
Any suggestions? On 2/3/06, سيد هادی راستگوی حقی <[EMAIL PROTECTED]> wrote: > > Dear all, > Thanks for your replies. > > The main table for me is traffic_log. I use combination of recipient_id > and mobile_retry fields to uniquely identify each row in the traffic_log and > use the same combination

Re: Query Complexity Limit Question [Newbie Question]

2006-02-07 Thread James Harvard
At 3:46 pm + 7/2/06, [EMAIL PROTECTED] wrote: >Yes, you can do multi-way joins, and people often do. My biggest is 3-way, but >some people do at least 5-way. My record is and 8-way join (7 tables, one twice). So there! ;-) >Beware that it is easy to specify operations which will heavily load

Re: Query Complexity Limit Question [Newbie Question]

2006-02-07 Thread David T. Ashley
On Tue, February 7, 2006 10:46 am, [EMAIL PROTECTED] wrote: > "David T. Ashley" <[EMAIL PROTECTED]> wrote on 07/02/2006 14:03:04: > >> a)Will MySQL allow joins that involve more than two tables (in my case, >> perhaps as many as 5)? >> >> b)Can limits on a key field be included in the join in the s

Re: Query Complexity Limit Question [Newbie Question]

2006-02-07 Thread Alec . Cawley
"David T. Ashley" <[EMAIL PROTECTED]> wrote on 07/02/2006 14:03:04: > Hi, > > I have several tables linked in various ways so that an inner join is > possible. However, at the same time and in the same SQL query, I'd also > like to query by some field values in one of the tables. > > Two quick

Re: Query Complexity Limit Question [Newbie Question]

2006-02-07 Thread nigel wood
David T. Ashley wrote: Hi, I have several tables linked in various ways so that an inner join is possible. However, at the same time and in the same SQL query, I'd also like to query by some field values in one of the tables. Two quick questions: a)Will MySQL allow joins that involve more th

Re: Query Speed

2006-02-03 Thread سيد هادی راستگوی حقی
Dear all, Thanks for your replies. The main table for me is traffic_log. I use combination of recipient_id and mobile_retry fields to uniquely identify each row in the traffic_log and use the same combination on status_log as my foreign key to traffic_log. Each message is saved as a row in traffic

Re: Query Speed

2006-02-02 Thread SGreen
Sorry, but you gave us a "best guess" situation. Your tables do not have any PRIMARY KEYs defined on them so I had to guess at what made each row in each table unique from all other rows in that table based only on your sample query. What value or combination of values will allow me to uniquel

Re: Query Speed

2006-02-01 Thread سيد هادی راستگوی حقی
Another question is that if I run such CREATE TEMPORARY statements in my query, is MySQL really can do it fast? Cause this query may be run periodically ! On 2/2/06, سيد هادی راستگوی حقی <[EMAIL PROTECTED]> wrote: > > Thanks for your suggestion, > I forget to tell that each message in traffic_log

Re: Query Speed

2006-02-01 Thread سيد هادی راستگوی حقی
Thanks for your suggestion, I forget to tell that each message in traffic_log may has at least 2 status in status_log and I use to columns "recipients_id" and "mobile_retry" to uniquely find each message's statuses. May be I have to change my tables structure. I don't know. It's really important f

Re: Query Speed

2006-02-01 Thread SGreen
سيد هادی راستگوی حقی <[EMAIL PROTECTED]> wrote on 02/01/2006 11:07:49 AM: > Dear All, > I need your suggestions please. > > have to large tables with these schemas: > > Table: traffic_log > Create Table: CREATE TABLE `traffic_log` ( > `recipient_id` int(11) NOT NULL default '0', > `retry`

<    1   2   3   4   5   6   7   8   9   10   >