Re: MAX + SUM in one query

2006-11-06 Thread Ahmad Al-Twaijiry
but what if I want also to include another table for example, can I do this : SELECT R.Stock_StockID,S.StockName, MAX(R.RequestPrice), SUM(R.RequestTotal) FROM Request R, StocksT S WHERE S.StockID=R.Stock_StockID AND R.RequestType='Offer' AND R.RequestENDDate=Date(now()) GROUP BY

Re: MAX + SUM in one query

2006-11-06 Thread Visolve DB Team
Hi The query will work and should. As of our understanding, you want to retrieve the sum of the total column for a particular id, with its max price where the type='offer' and id same for both the tables. Is it so? Thanks ViSolve DB Team. - Original Message - From: Ahmad Al-Twaijiry

Re: Convert hex to decimal?

2006-11-06 Thread Martijn Tonies
I have a table with a SMALLINT column that -- trough a mistake -- contains values like 57, 13 etc. which in fact are 0x57 and 0x13 (i.e. HEX numbers). How would I convert 13 (false decimal) to 0x13 (Hex) and from there to 19 (decimal)? I tried my luck with UNHEX and CAST but I only got 0

Re: Default Column Value

2006-11-06 Thread Martijn Tonies
Alternatively one could use a TRIGGER that updates the start_yr_mo whenever start_date is modified but I'm unsure if triggers are present before 5.1. Triggers are new in 5.0 Martijn Tonies Database Workbench - development tool for MySQL, and more! Upscene Productions http://www.upscene.com

Re: MAX + SUM in one query

2006-11-06 Thread Ahmad Al-Twaijiry
This didn't work. To explain in easy way, let say I have this table ID, OrderID, Price, Total, Type 1 200 100 20 Offer 2 200 700 40 Offer 3 200 700 30 Offer 4 300 100 60 Offer 5 300 500

Re: Convert hex to decimal?

2006-11-06 Thread Dušan Pavlica
Frederic Wenzel napsal(a): Hey, I have a table with a SMALLINT column that -- trough a mistake -- contains values like 57, 13 etc. which in fact are 0x57 and 0x13 (i.e. HEX numbers). How would I convert 13 (false decimal) to 0x13 (Hex) and from there to 19 (decimal)? I tried my luck with

Re: MAX + SUM in one query

2006-11-06 Thread Arjan Hulshoff
Are you looking for a query like this? select r.Stock_StockID, sum(r.RequestTotal), r.RequestPrice from Request r join (select x.Stock_StockID, max(x.RequestPrice) as MaxRequestPrice from Request x group by x.Stock_StockID) s on r.Stock_StockID = s.Stock_StockID and s.MaxRequestPrice =

Sorting MySQL queries

2006-11-06 Thread Dotan Cohen
I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in MySQL and being retrieved via php. I currently organize them alphabetically with MySQL's ORDER BY ASC argument, however, if there is a preceding the or a then that is considered as part of

Re: Sorting MySQL queries

2006-11-06 Thread Christian Hammers
On 2006-11-06 Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in MySQL and being retrieved via php. I currently organize them alphabetically with MySQL's ORDER BY ASC argument, however, if there is a preceding the or

Copy to tmp table optimize

2006-11-06 Thread Francis
Hi list, An others question, I am working on projet and i made some test. I use large databases, some table go up to 1.8g. The problem we have is wend I try to select data in table whit a group by function and I got Copy to tmp table This function take a long time to execute. I check on

Re: Copy to tmp table optimize

2006-11-06 Thread Rolando Edwards
You need to look at the GROUP BY clause If all the columns from a GROUP BY clause are not indexed or if the columns in the GROUP BY clause are from different tables, MySQL will use the temp table. Please send your query to the MySQL List and the structure of all tables in the query -

Re: Sorting MySQL queries

2006-11-06 Thread Dotan Cohen
On 06/11/06, Christian Hammers [EMAIL PROTECTED] wrote: On 2006-11-06 Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in MySQL and being retrieved via php. I currently organize them alphabetically with MySQL's ORDER BY

RE: Copy to tmp table optimize

2006-11-06 Thread Francis
Hi This is my SQL command: Select cs_documents.str_url FROM logs_2006_11 LEFT Join cs_documents ON int_url_strem = cs_documents.id where logs_2006_11.int_bots = 0 And ( cs_documents.str_url LIKE '%.asp' Or cs_documents.str_url LIKE '%.php' Or cs_documents.str_url LIKE '%.html' Or

Re: Copy to tmp table optimize

2006-11-06 Thread Rolando Edwards
As for this part of your query ( cs_documents.str_url LIKE '%.asp' Or cs_documents.str_url LIKE '%.php' Or cs_documents.str_url LIKE '%.html' Or cs_documents.str_url LIKE '%.htm' Or cs_documents.str_url LIKE '%.jsp' Or cs_documents.str_url LIKE '%.aspx' Or cs_documents.str_url

Re: Sorting MySQL queries

2006-11-06 Thread Christian Hammers
On 2006-11-06 Dotan Cohen wrote: Make a second column that only contains ALTER TABLE table ADD cooked_subject; UPDATE table SET cooked_subject = ereg_replace('^(a|the) ', '', subject); (I don't know how the regular expression function was called exactly but you get the idea)

RE: Copy to tmp table optimize

2006-11-06 Thread Francis
id, select_type, table, type, possible_keys, key, key_len, ref, rows, Extra 1, 'SIMPLE', 'logs_2006_11', 'ALL', 'date,time', '', , '', 3302388, 'Using where; Using temporary; Using filesort' 1, 'SIMPLE', 'cs_documents', 'eq_ref', 'id', 'id', 3, 'trafix_sites_00026.logs_2006_11.int_url_strem', 1,

Re: Copy to tmp table optimize

2006-11-06 Thread Rolando Edwards
1, 'SIMPLE', 'logs_2006_11', 'ALL', 'date,time', '', , '', 3302388, 'Using where; Using temporary; Using filesort' This line in the EXPLAIN plan reveals that the temporary table must be used which must go through 3302388 rows to complete You may want to store the file extension as a separate

Re: Convert hex to decimal?

2006-11-06 Thread Frederic Wenzel
On 11/6/06, Dušan Pavlica [EMAIL PROTECTED] wrote: How would I convert 13 (false decimal) to 0x13 (Hex) and from there to 19 (decimal)? conv('column_name', 16, 10) Thanks, that works! Fred -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:

When are subselects faster than Joins?

2006-11-06 Thread Robert DiFalco
Are there any hard and fast rules for this? If someone has already compiled a list I'd love to see it. For example: * When a subselect will eliminate duplicates a join might introduce. Change: SELECT DISTINCT Acl.* FROM Acl JOIN Link ON Link.childID = Acl.ID JOIN Paths ON

Re: MyISAM vs InnoDB

2006-11-06 Thread Leandro Guimarães Faria Corcete DUTRA
Em Fri, 03 Nov 2006 09:18:21 +0100, Martijn Tonies escreveu: On two-phase commits? I guess it's the IB 6 docs where you have to read that, or get a copy of Helen Borries Firebird book. Get a copy of the IBPhoenix CD that includes docs. The Firebird project itself has no full documentation

Re: MyISAM vs InnoDB

2006-11-06 Thread Leandro Guimarães Faria Corcete DUTRA
Em Thu, 02 Nov 2006 10:22:18 -0800, Jochem van Dieten escreveu: PostgreSQL supports 2 phase commit. IIRC except for transaction interleaving, join and suspend/resume it supports XA. I think that puts it about on par with Ingres and Firebird. I would have to analyze better, but I think

Re: MyISAM vs InnoDB

2006-11-06 Thread Martijn Tonies
On two-phase commits? I guess it's the IB 6 docs where you have to read that, or get a copy of Helen Borries Firebird book. Get a copy of the IBPhoenix CD that includes docs. The Firebird project itself has no full documentation yet - it's being worked on. Hm, do you mean 2PC are

Preventing SQL injection

2006-11-06 Thread Dotan Cohen
I'm creating a forum in php where users are able to store comments in a text field (think blog comments). To prevent SQL injection, I'm using the php function mysql_real_escape_string() on data going into the text field. Is this really enough to be safe, or should I be doing more? Thanks in