Re: Multiple primary keys

2006-04-27 Thread Gordon
MySQL will not use the primary key unless you use the left most columns. For a 1 column primary key then it's easy. For a 2 column primary key you can either use the 1st column in the primary key or both columns. If you only reference the 2nd column the query will not use the primary key and wil

RE: Baffled by error

2006-05-16 Thread Gordon
Try this SELECT c.account_id, a.name,a.company, SUM(c.agent_product_time) AS mins FROM account a LEFT JOIN calls c ON c.account_id = a.id WHERE c.calldate >= DATE_SUB(NOW(),INTERVAL 14 DAY) AND c.agent_id = 9 GROUP BY a.account_id HAVING SUM(c.agent_pr

RE: Accountability with MySQL

2006-03-16 Thread Gordon
And now we are down to reality. This is a MySQL list. Views are a wonderful thing for creating an isolation layer between the application and the database. However, MySQL's current implementation makes it extremely difficult in many cases to avoid full table scans when you define the logical view.

RE: getting table metadata

2006-03-17 Thread Gordon
What you are looking for is the INFORMATION_SCHEMA views, but they are not available before 5.0. Until then you have to parse the "show create table" or "DESCRIBE tablename" may be easier to parse mysql> describe organizations; +---+

RE: Some queries use 100% CPU after restore

2006-03-17 Thread Gordon
Have you tried Repair table or if InnoDB ALTER TABLE ENGINE=InnoDB; Sometimes I've noticed after a restore or after adding lots of rows performance is slow. REPAIR or the ALTER TABLE fixes it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, March 17,

RE: Easy regex replace?

2006-03-20 Thread Gordon
If "%20" are the actual characters in the varchar column you shuld be able to do UPDATE table SETcolumn_name =REPLACE(column_name,'%20',' '); You might have to use REPLACE(column_name,'\%20',' '); to force MySQL to treat "%" as an actual value instead of a wild card. -Original Message-

InnDB disabbled on 5.1.7

2006-03-24 Thread Gordon
We are running 2.6.15-gentoo Linux and downloaded the max binaries for 5.1.7. With the following my.cnf I thought we should have InnoDB. All of the InnoDB files got created but show variables like 'have%'; displays " have_innodb DISABLED". Exactly the same my.cnf {except the skip bdb is not commen

RE: Stored procedures and views

2006-03-24 Thread Gordon
If the features available in stored procedures {i.e. looping etc.} are required, have you tried having the procedure 1st write/edit the data in a temporary table and at the end select the values you want from that table. I think I might write 2 procedures. One that does the data manipulation an

RE: Reserevd Error -7776 -- Urgent

2006-04-07 Thread Gordon
I have been linking MySQL tables into access for versions 3.23 thorough 5.17. The only way I have been able to deal with insert/update tables with a timestamp field is to build a query which includes all of the fields except the timestamp field. You can then do your insert or update against the que

RE: FW: New to TRIGGER and CALL. Example gives errors. (repost)

2006-04-12 Thread Gordon
REMOVE the semicolon ";" from " END;//" SQLyog has a problem with all of the procedures, functions and triggers RE the DELIMITER syntax. > -Original Message- > From: Daevid Vincent [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 11, 2006 10:00 PM > To: mysql@lists.mysql.com > Cc: 'Shawn

RE: ORDER BY question

2007-03-21 Thread Gordon
I think you can also do SELECT *, DATE_FORMAT(deadline, '%d-%m-%Y') AS deadline_f, Status + 0 AS sorted_grade FROM v_issue_project_task ORDER BY sorted_grade That way you do not have to change the code if you add a value t

RE: Giving Back...Well, Maybe

2007-04-29 Thread Gordon
Just one suggestion re the behavior of special characters between file input and command line input. Try using char(10) {I think that is new line} instead of \n. That should work in both scenerios. -Original Message- From: John Kebbel [mailto:[EMAIL PROTECTED] Sent: Saturday, April 28, 20

RE: Order By and Ignore Punctuation

2007-05-04 Thread Gordon
Try something like this. If there are multiple punctuation values you want to ignore you can nest multiple REPLACE functions. mysql> create table names (name varchar(20)); Query OK, 0 rows affected (0.01 sec) mysql> insert into names values ('Osbourn'),("O'shea"),("O'Malley"),('Olathe'),('Ottawa

used command isn not allowed

2007-06-19 Thread Gordon
I tried running this load data command on Server version: 5.0.27 and get the 1148 error. I'm not sure if it is referring tho the comand client or the server. I also do not understand why the command {or which part} it is complaining about. Probably something obvious, but I just can't see it. A

RE: select where multiple joined records match

2005-02-14 Thread Gordon
Try this Select * from resources, goals where resources.ID = goals.RESOURCE_ID and (SUBJECT="English" and GRADE="1") OR (SUBJECT="English" and GRADE="2"); -Original Message- From: AM Thomas [mailto:[EMAIL PROTECTED] Sent: Sunda

RE: Query problem

2005-02-18 Thread Gordon
Did you want WHERE Name LIKE 'sandy' OR (main_data.Display_In_Search = 1 AND main_data.Expiry_Date >= CurDate()) OR WHERE main_data.Expiry_Date >= CurDate() AND (Name LIKE 'sandy' OR main_data.Display_In_Search = 1 ) -Original Message

RE: how to write this query?

2005-02-21 Thread Gordon
This works if you don't care about holidays. If you do the only solution that I have seen that works is to create a business day table. Ours is shown below. You have to hand construct the calendar by removing weekends and holidays for the specific entity. This calendar forces a non business day DA

RE: Odd rounding errors with 4.1

2005-02-23 Thread Gordon
This reminded me of one more difference between Windows and Linux/Unix. MySQL use the round function out of the host libraries. If you are on a Windows box the rule for rounding is if the column immediately to the right of the column you are rounding to is a 5 then round up i.e. make 2.485 >>>

RE: select date_format('2004-10-03 15:06:14','%m/%d/%y %T');

2005-03-08 Thread Gordon
I have > 200 tables with regular datetime fields. I link these tables through ODBC to an ACCESS database where I can run standard ACCESS append queries or even copy/paste append into the linked table. ODBC handles the conversion just fine. One caution, MySQL timestamp maps to ACCESS datetime but

RE: Use MySQL with Microsoft Office

2005-03-08 Thread Gordon
If Publisher XP's mail merge can find data in ACCESS try linking the tables into an ACCESS database and then tying Publisher to the ACCESS database. Sounds klunky but it might work. -Original Message- From: GH [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 08, 2005 9:37 AM To: J.R. Bulli

RE: Slow queries only the first time

2005-03-10 Thread Gordon
The key to your question is InnoDB. InnoDB keeps data and indexes in its buffer using LRU to flush. So the 2nd time your data was already in memory. Depending on your buffer size and database size you have all of the advantages of a memory resident database for frequently used data without the dis

RE: Trouble performing an update

2005-03-16 Thread Gordon
You can do left joins in an update. mysql> show create table t; +---+--- -- | Table | Create Table +---+--- -- | t | CREATE TABLE `t` ( `key1` int(1

RE: design: table depending on a column

2005-04-12 Thread Gordon
As long as articles.annotationID can be made distinct from names.annotationID why not use 2 left joins. You may have to test annotationType in the select section to map the fields. Something like the following. SELECT elements.annotationID, CASE annotationType WHEN 'names' T

RE: Help with a tricky/impossible query...

2005-04-14 Thread Gordon
One way would be to build a "count" table with one column starting with value 1 and incrementing by 1 up to say 500 rows or how many your max y value is. Then just select seq,val from wibble,count where val between x and y create table count (val INT unsigned default '0' not null primary key)

ACCESS ODBC Interface whit 5.0.4

2005-05-04 Thread Gordon
I have been using ACCESS to do simpe data editing on our MySQL tables for 3 years. I recently installed 5.0.4 on my machine to evaluate it. I linked the tables into ACCESS through my old ODBC driver and got ODBC-update on a linked table 'product_order_choice' failed [Microsoft][ODBC Driv

RE: ACCESS ODBC Interface whit 5.0.4

2005-05-05 Thread Gordon
(14) NOT NULL, `poch_Create` datetime NOT NULL default '-00-00 00:00:00', PRIMARY KEY (`cpny_ID`,`prod_ID`,`porc_Look_Up_Type`,`prft_Sub_Month`,`prft_Sub_Item`,`p och_Name`) ) TYPE=InnoDB | ---+ 1 row in set (0.00 sec) mysql> -Original Message---

RE: ACCESS ODBC Interface whit 5.0.4

2005-05-05 Thread Gordon
> Has anyone else seen this or have any ideas? > "Gordon" <[EMAIL PROTECTED]> wrote: -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.NET http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __

RE: Read past Equivalent in MySQL

2005-05-13 Thread Gordon
If you can add a table structure why not create a SELECTED table with REPORT ID and PERSON ID as the 2 field PRIMARY KEY. Then you could INSERT IGNORE into this table [with no BEGN/COMMIT] and the IGNORE would throw away those already selected. -Original Message- From: Duncan Hill [mailto

RE: varchar(10) to decimal

2005-05-18 Thread Gordon
I was all set to tell you why 16.125 became 16.12 when I ran the test on our production box. It looks like some where between 4.0.20 and 5.0.4 the ALTER TABLE to a decimal data type changed from truncation to rounding. Redhat MySQL 4.0.20 truncates all Windows XP MySQL 5.0.4 Rounds with Windows a

RE: DB design question

2005-05-24 Thread Gordon
You probably want to add type to both the address and phone tables. Then you can be selective in your reporting and still get 1 row per student in your result set. Just remember if your data has the possibility of not having the information for a student you want to use LEFT JOIN's vs INNER JOIN's

RE: LOAD DATA and skip columns in text file...

2005-05-25 Thread Gordon
The folowing is out of the current MySQL manual. It looks like you could create an intermediate table with the fields you are interested in the front and "garbage" fields on the end. Then build a specific LOAD DATA INFILE with correct mapping for each file type [assuming you can tell this in your a

RE: Database design query

2005-05-31 Thread Gordon
IF GroupID, HostID and UserID are unique between the three sets then your GroupMember table will work although I would still be tempted to add a MemberType in the GroupMember table. Isn't MemberID the Foreign Key to UserID/HostID/GroupID althugh I don't know if you can have three different foreig

RE: Mysqldump

2005-06-02 Thread Gordon
If you just dump the structure with mysqldump and then build SELECT INTO OUTFILE and LOAD DATA INFILE statements for each table, the process will run faster than even the "extended insert" option of mysqldump. -Original Message- From: ManojW [mailto:[EMAIL PROTECTED] Se

RE: copy from table to it again

2003-12-10 Thread Gordon
If you want to change the value in qid to 3 when it is 0 You really need an update update answer setqid = 3 where qid = 0 -Original Message- From: ÇÈæ ÇÈÑÇåíã [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 10, 2003 8:14 AM To: [EMAIL PROTECTED] Subject: copy from table to it

Excluding Tables from mysqldump

2003-12-12 Thread Gordon
We have 2 tables which are roughly half the size of the entire database { ~1.5GB}. These 2 tables are rarely changed {1-2 times a quarter}. Is there a way in mysqldump to exclude these two tables without specifically naming all of the tables { > 100} we want to include?

non unique index on MySQL 5.0

2004-02-09 Thread Gordon
I just installed MySQL 5.0 on my windows machine and was trying to load the output from a MySQLFront export from our 4.0.16 production system when I got the following error.. C:\>mysql -u root mailprint < e:\mp20040205.sql ERROR 1062 at line 7893168: Duplicate entry 'Name-4928 N Brooklyn Kansas

RE: non unique index on MySQL 5.0

2004-02-09 Thread Gordon
Sorry for the repost, but I just realized that the index information for key 3 did not get copied into the 1st email. -Original Message- From: Gordon [mailto:[EMAIL PROTECTED] Sent: Monday, February 09, 2004 8:48 AM To: [EMAIL PROTECTED] Subject: non unique index on MySQL 5.0 I just

RE: SELECTing last occurences from a table

2003-06-02 Thread Gordon
It is possible if you make the number of digits in day all the same by using something like lpad. The secret is to tie all of the values you want together with something like CONCAT and making sure that the resulting string sorts in the order you want with its alphabetic sort sequence. Then MAX gi

MySQL Multi Table Delete

2003-07-16 Thread Gordon
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the results below, I would think that the delete should have deleted row 1 {1 5 me) and not row 3 (1 5 th

Any Issues with 3.23.56 and 4.0.13 using mysqld_multi on one server

2003-07-31 Thread Gordon
Is it possible to run 3.23.43 and 4.0.13 on the same server? I don't see anything in the documentation that should prohibit this as long as the installations are in different directories, use different sockets/ports and data directories. Can this be done utilizing mysqld_multi and if so are ther

RE: weird kind of join

2004-09-29 Thread Gordon
You might also try FROM table_a INNER JOIN table_b ON table_b.code = substring_index(table_a.code,';',1) SUBSTRING_INDEX(str,delim,count) Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final deli

RE: matching people with projects via resources

2004-10-01 Thread Gordon
This may not be elegant, but why not define a 3rd table proj_c containing proj and project_rsrc. This assumes that when you define a project you know how many resources are required. CREATE TABLE proj_c ( proj varchar(11) default NULL, project_rsrc INT default 0); INSERT INTO proj_c VALU

RE: Yet another LEFT JOIN question

2004-12-06 Thread Gordon
Try something like this SELECT A1.ID, SUM(IF(ISNULL(C.AdID),0,1)) AS Clicks, SUM(IF(ISNULL(V.AdID),0,1)) AS Views FROM Ads A1 LEFT JOIN Clicks C ON A1.ID = C.AdID LEFT JOIN Views V ON A1.ID = V.AdID GROUP BY A1.ID -Original Message- From:

RE: How to select every second record

2005-01-27 Thread Gordon
Try this. The second set ... select gives you what you want. However, the group by may interfere with the rest of your logic. You also don't really need the mod(@a,2) in the result set, just in the having. mysql> set @a:=0; Query OK, 0 rows affected (0.00 sec) mysql> select @a:[EMAIL PROTECTED],m

RE: Syntax Failures with SELECT SUBSTRING - Help!

2005-02-03 Thread Gordon
Try SELECT SUBSTRING(AnimalName, 1, 1) MySQL wants the "(" to immediately follow the function i.e. no spaces. -Original Message- From: Sue Cram [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 9:28 AM To: mysql@lists.mysql.com Subject: Syntax Failures with SELECT SUBSTRING - H

FW: Backup / Restore

2004-09-06 Thread Gordon
We have built an alternative save restore process. First we take all of the .frm files and build "select * into outfile '/path/tablename.txt' from tablename" statements. We also dump the structure only and put it in the same directory. This runs much faster than myysqldump and every t

Autoincrement in MYISAM vs INNODB

2003-10-17 Thread Gordon
It is my understanding that at least through 4.0.14, INNODB does not support using autoincrement on the last field in a multi field primary key. i.e. if a table has a primary key of three fields like cpny_ID, acct_ID, list_ID in MYISAM you can add the autoincrement attribute to list_I

System time vs MySQL time

2003-10-31 Thread Gordon
We are running MySQL 4.0.14 on redhat 8.0. The server and MySQL have been running fine for over 60 days. Sometime yesterday afternoon the time reported in mysql using mysql> select now(); +-+ | now() | +-+ | 2003-10-31 20:22:36 | +---

FW: Strategies for optimizing a read-only table

2003-11-10 Thread Gordon
What about making the table INNODB? If you make INNODB's buffer large enough, the high activity data/index blocks are retained in memory. INNODB's non blocking read and single statement transaction default should make the "transaction overhead" minimal and INNODB doesn't have any of the HEAP table

Interfaces to 5.0.0

2004-03-23 Thread Gordon
A few weeks ago I download the windows version for 5.0.0 and installed it on my machine. After successfully installing the new version I was able to connect with all of my old tools including MyCC 0.9.3, MySQLFront, SQLyog, cmd and MySQL Administrator. Yesterday I downloaded the 5.0.0 RPM's for l

MySQL function

2004-04-13 Thread Gordon
Has anyone out there written a Credit Card Validation routine as a user-definable function (UDF)? We now have a requirement to collect credit card data through our Web Site. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com

DELETE with no WHERE clause

2002-12-23 Thread Gordon
DID DELETE FROM XXX with no where clause stop acting like truncate in 4.0.5? In 3.23.51 and earlier versions of 4.0.x mysql> delete from product_order_main; GIVES THIS Query OK, 0 rows affected (0.10 sec) AND RESETS THE AUTOINCREMENT VALUE mysql> insert into product_order_main values (

Left join returns records it shouldn't

2003-01-22 Thread gordon
8','IN',NULL,'A',NULL,'bc35afd157ffa6c8729557a6fb62810d','gordonb','2003-01-20 17:12:25',234,'Y'); INSERT INTO dns_rec VALUES ('00105a3bcac286c9f9487dfe896ad220','0b','IN',NULL,'A',NULL,&#

RE: buggy round()

2002-03-03 Thread Gordon
if end if I built an Excel spreadsheet and the "regular" round routine introduced a 10 times larger round error than the one above on ~200 values. Gordon Interstate Software A MySQL training partner - Before posting,

FW: Difficulties between OS versions

2002-04-10 Thread Gordon
Two of my co-workers attended the MySQL training in San Francisco last month. We have successfully installed 4.01 on a SUN Ultra 250 running Solaris 2.8. Four myisam tables were created and populated. When we tried to install the same software on a SUN Sparc 20 running Solaris 2.6 errors were

RE: LOOKUP

2002-04-18 Thread Gordon
data/ENUM relationships for any values already in the table which fall after the value in the list which you removed. Either just add another table and do joins or live with only being to add to the list. Gordon Bruce Interstate Software A MySQL Training Partner > -Original Message- &

RE: how to delete from one table based on external conditions?

2002-04-18 Thread Gordon
QUICK] FROM table_name [WHERE where_definition] [ORDER BY ...] [LIMIT rows] or DELETE [LOW_PRIORITY | QUICK] table_name[.*] [table_name[.*] ...] FROM table-references [WHERE where_definition] Gordon Bruce Interstate Software A MySQL Training Partner > -Original Message- >

RE: delta between rows?

2002-04-29 Thread Gordon
1.5 | |4 | 5.0990463257 | |5 | -1.7971389771 | +--+---+ 4 rows in set (0.00 sec) Gordon Bruce A US MySQL Training Partner > -Original Message- > From: Nissim Lugasy [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 24, 2002 2:57 PM > To: [

RE: geometric mean aggregate function

2002-05-11 Thread Gordon
e details below Gordon Bruce Interstate Software A MySQL US Training Partner mysql> create table g_mean (test_val float); Query OK, 0 rows affected (0.02 sec) mysql> insert into g_mean values (23),(32),(12),(145),(18); Query OK, 5 rows affected (0.00 sec) Records: 5 Duplicates:

RE: Filemaker Pro and Dates

2002-05-29 Thread Gordon
PPEND query to copy the Access tables into the MySQL tables Delete the Access database after verifying success Moving the dates through the ODBC interface automatically converts the DD-MM- format to the -MM-DD format used by MySQL. Gordon Bruce Interstate Software US MySQL Training P

RE: Surrounding Rows

2002-07-22 Thread Gordon
gits or you can add 0's on the end of your 5 digit ZIP's with RPAD(). Gordon Bruce Interstate Software A MySQL Training & Consulting Partner > -Original Message- > From: Jan Peuker [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 22, 2002 12:54 PM > To: Gurhan Ozen

RE: Table Design

2002-07-23 Thread Gordon
with MyISAMPACK and MERGE could make queries against on the whole data set run much faster. Gordon Bruce Interstate Software A MySQL Training & Consulting Partner > -Original Message- > From: Daren [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 23, 2002 4:45 AM > To: [EM

RE: rounding?!

2002-07-23 Thread Gordon
Try round(value*4,0)/4 Worked on the samples I tried > -Original Message- > From: Nicholas Stuart [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 23, 2002 1:47 PM > To: [EMAIL PROTECTED] > Subject: rounding?! > > Ok here's the problem. Trying to write a select statement to be able to >

RE: removing duplicate records

2002-07-31 Thread Gordon
If you use IGNORE in the insert IGNORE into new_table you will get the result you want. > -Original Message- > From: walt [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 30, 2002 3:11 PM > To: David Kramer; [EMAIL PROTECTED] > Subject: Re: removing duplicate records > > Thanks David! >

RE: A difficutl query I cannot do.

2002-01-13 Thread Gordon
The following SELECT should produce your table mysql> Select id, ->Max(CASE TimeSlot -> WHEN 1 THEN Subject ->ELSE "" ->END) AS TS1, ->Max(CASE TimeSlot -> WHEN 2 THEN Subject ->ELSE "" -

RE: Converting Access 2000 to Mysql

2002-01-28 Thread Gordon
There is a program at http://www.convert-in.com/acc2sqlp.htm which will create the MySQL tables from the Access 2000 database and populates created tables directly from the Access 2000 source. It also converts date/datetime fields into MySQL format and Yes/No fields into tinyint. The best news is

RE: Using LIMIT to select random rows

2002-01-28 Thread Gordon
This is an example from MySQL's class on Using MySQL MySQL> Select Name -> From Country -> Where Continent="Europe" -> Order By RAND() -> LIMIT 1; If you do Limit 3 you should get 3 random rows. -Original Message- From: Ulf Harnhammar [mailto:[EMAIL PROTECTED]] Sent: We

MySQL GRANTS

2002-09-12 Thread Gordon
ution? I don't seem to find it in Gordon Bruce Oh, if you GRANT ALL ON *.* instead of .* with MySQL Front you don't get the SHOWDATABASES, CREATE TEMPORARYTABLES and LOCK TABLES privileges.

RE: Problem with select.

2002-10-26 Thread Gordon
This is what happens when you use LIMIT MySQL retrieves the entire record set for the select and then sends the number requested in the LIMIT parameter to the client. MySQL has to retrieve the entire result set to accommodate a LIMIT clause which skips n records i.e. LIMIT 250,10. With no ORDER B

RE: update and data manipulation

2002-10-31 Thread Gordon
Use the concat function. It takes any number of arguments. mysql> create table test (a char(5)); Query OK, 0 rows affected (0.04 sec) mysql> insert into test values ('A'); Query OK, 1 row affected (0.02 sec) mysql> select * from test; +--+ | a| +--+ | A| +--+ 1 row in set (0.

RE: Intersting MySQL / Access Issue

2005-06-22 Thread Gordon Bruce
When I have seen this error it was caused by a field defined in the MySQL database as NOT NULL in the Create table and the value in Access is NULL or usually for us an empty field in EXCEL which is appears to be intreped as NULL when you do a PASTE APPEND. Ours is often times a datetime field but

RE: question about field length for integer

2005-06-27 Thread Gordon Bruce
If you really need more than 20 digits of accuracy and can move to 5.0.3 + you can use the Decimal data type without losing precision. This is out of Chapter 23. Precision Math The maximum value of 64 for M means that calculations on DECIMAL values are accurate up to 64 digits. This limit of 64

RE: Count(*)

2005-07-07 Thread Gordon Bruce
select count(distinct ordr_ID) from store -Original Message- From: Gana [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 3:01 PM To: mysql@lists.mysql.com Subject: Count(*) select count(*) from store group by orederId. For the above sql, I am not getting the count of unique orde

RE: Impossible join?

2005-07-18 Thread Gordon Bruce
Here is one way. Some time ago I set up a table named count with one field named count and built 5000 rows of incrementing values . I think I originally populated it by originally createing it with a 2nd field CREATE TABLE `count` ( `count` int(10) unsigned NOT NULL auto_increment, `add

RE: Renaming a database

2005-07-18 Thread Gordon Bruce
A database in MySQL is simply a directory.   So just rename the directory with appropriate tool for your platform. On my test box this becomes   mysql> show databases; ++ | Database   | ++ | information_schema | | lois 

RE: advanced group by

2005-08-03 Thread Gordon Bruce
Something like this SELECT CompanyName, WhatToShip, SUM(IF(TrackingNumber = '', IF(SerialNumber = '', 1, 0), 0) ) AS READY, SUM(IF(TrackingNumber <> '', IF(SerialNumber = '',

Number of SQL Queries curiosity

2005-08-05 Thread Gordon Bruce
We have a relatively small web site running 4.0.20 on a Dell 2850 running RedHat. We rarely see any SQL statements visible when we run SHOW PROCESSLIST and typically use 30 - 40 concurrent connections. The Number of SQL Queries graph in MySQL Administrator usually is in the 0 to 10 range wit

RE: top one row

2005-08-05 Thread Gordon Bruce
This is out of the MySQL class and is called the Max-Concat trick. What is the biggest country in each continent? "The Rows Holding the Group-wise Maximum of a Certain Field" MySQL> Select Continent, -> SUBSTRING(M

RE: JOIN QUERY -> UPDATE ... help?!

2005-08-09 Thread Gordon Bruce
Multi Table UPDATES are first supported in 4.0.x -Original Message- From: Brendan Gogarty [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 09, 2005 12:16 PM To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Subject: RE: JOIN QUERY -> UPDATE ... help?! "Brendan Gogarty" <[EMAIL PROTECTED]>

RE: Index - max key length is 1024 bytes

2005-08-12 Thread Gordon Bruce
If you are on a version prior to 4.1.2 the max index size is 500 bytes {not sure why the error mentions 1024} >From section 14.1 of documention The maximum key length is 1000 bytes (500 before MySQL 4.1.2). This can be changed by recompiling. For the case of a key longer than 250 bytes, a larger

RE: query

2005-08-16 Thread Gordon Bruce
You can use INTERVAL i.e. Lets say you have a table mysql> CREATE TABLE foo (bar int(14), fdate date ); Query OK, 0 rows affected (0.27 sec) mysql> INSERT INTO foo > VALUES (1, now()), (25,now() - INTERVAL 1 DAY), (15,now() - INTERVAL 2 DAY); mysql> SELECT f1.

RE: SELECT ... INTO OUTFILE ... and LOAD DATA INFILE ... with a key

2005-08-19 Thread Gordon Bruce
If you want to have all values except the primary key be the same and say your is foo_ID You can simply do INSERT INTO foo (foo_ID... {rest of columns list}) SELECT new primary key value, {rest of columns list} FROM foo WHERE foo_ID = {primary key value of row you want to copy} If

RE: Date arithmetic: 2005-08-31 - 1

2005-08-23 Thread Gordon Bruce
Do You know about INTERVAL? Use it in an exprecssion or funtion as ..INTERVAL expr type where expr is any numerical value * The INTERVAL keyword and the type specifier are not case sensitive. The following table shows how the type a

RE: Treating Two Fields Like One

2005-08-24 Thread Gordon Bruce
I think you misunderstand how auto_increment works. Primary keys using auto_increment are NOT row numbers. If your table has a primary key that is an auto_increment field then when you add a row to the table the value of the primary key of the new row is 1 greater than the max(Value) before the ro

RE: Compare two tables

2005-08-26 Thread Gordon Bruce
If you have the 5.0.x version of MySQL then INFROMATION SCHEMA can give you what you want. i.e. SELECT a.*, b.* FROM INFORMATION_SCHEMA.COLUMNS AS a INNER JOIN _SCHEMA.COLUMNS AS b ON (a.column_name = b.column_name) WHERE a.TABLE_NAME = 'foo_1' AND b.TABLE_NAME = 'foo

RE: Union vs OR

2005-08-26 Thread Gordon Bruce
It's getting late on Friday, but couldn't you build a table with all of the parameter combinations and then just join against that table? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, August 26, 2005 4:25 PM To: mysql@lists.mysql.com Subject: Union vs

RE: insert subquery

2005-09-23 Thread Gordon Bruce
What am I missing INSERT INTO table1 (column names.) SELECT VALUES.. FROM table2 WHERE primary id = insert value You will have to put in your real table name and column names. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 200

RE: strange order by problem

2005-09-27 Thread Gordon Bruce
Try this mysql> select distinct secname, date -> from optresult -> where secname like 'swap%' ->and date like '2005-09-2%' -> order by if(secname like 'swap%', -> (mid(secname,5,20)+0), -> secname); +--++ | secname | d

RE: how to list foreign keys

2005-10-05 Thread Gordon Bruce
IF you are on 5.0.x you can use INFORMATION_SCHEMA 21.1.13. The INFORMATION_SCHEMA KEY_COLUMN_USAGE Table http://dev.mysql.com/doc/mysql/en/key-column-usage-table.html -Original Message- From: Operator [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 05, 2005 3:02 PM To: mysq

RE: [SPAM] - Query help - Bayesian Filter detected spam

2005-10-11 Thread Gordon Bruce
You might try UNION with the 1st statement pulling all products with groupid = 0 and the 2nd pulling 1 product with groupid > 1. -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, October 10, 2005 3:31 PM To: MySQL List Subject: [SPAM] - Query help - Bayesian Fil

Sub Selects, Alias Names and stored procedures

2005-11-04 Thread Gordon Bruce
After reading one of the recent posts from Gobi [EMAIL PROTECTED] I took his successful query and modified it for one of my tables. It indeed produce the correct result, but in the process raised some questions. 1. Why do list_ID and acct_ID not have to be qualified with a table name or

RE: SQL Statement Conversion

2005-11-04 Thread Gordon Bruce
If your MySQL server is a *nix system than table names are case sensitive. SELECT A.*, CASE CounselorOnly WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' END AS CO FROM Activities A ORDER BY Activity I also just noticed, remove the "CO =" and add "AS CO" following the END

RE: Help optimize this simple find

2005-11-07 Thread Gordon Bruce
Is it possible to change the geocodes table to look like CREATE TABLE `geocodes` ( `ip` int(10) unsigned zerofill NOT NULL default '00', `lat` double default NULL, `lon` double default NULL, PRIMARY KEY (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Then you could do SELE

RE: Query producing default values

2005-11-09 Thread Gordon Bruce
Try this {I wasn't sure whether cd_nature_ltr is in ligne_trans or transaction. This assumes ligne_trans. If it is in transaction thatn move "cd_nature_ltrsn = 2" into the ON clause.} SELECT CASE id_ltrsn WHEN NULL THEN 0 ELSE id_ltsrn END AS id_ltrsn, CASE

RE: Format for saving date field.

2005-11-10 Thread Gordon Bruce
What is the source of the data that is displayed on the screen. If it is a field in a MySQL table and the data type for that field is either DATE or DATETIME then it will intsert/update without any manipulation. Try doing a SELECT datefield FROM table Limit 15; outside of your ASP.NET envi

RE: copying data!!!

2005-12-09 Thread Gordon Bruce
This is kind of ugly, but with the multitable limitations of 3.23 it probably works. CREATE TABLE TEMP SELECT table_1 columns except age, table_2 age FROM table_1 INNER JOIN table_2 USING (name); TRUNCATE table_1; INSERT INTO table_1 SELECT * FROM TEMP; DROP TABLE_1; --

RE: copying data!!!

2005-12-09 Thread Gordon Bruce
Sorry the DROP TABLE Should be TEMP not table1 -Original Message- From: Gordon Bruce [mailto:[EMAIL PROTECTED] Sent: Friday, December 09, 2005 3:51 PM To: Sachin Bhugra; mysql@lists.mysql.com Cc: [EMAIL PROTECTED] Subject: RE: copying data!!! This is kind of ugly, but with the

RE: [SPAM] - Re: locating ibdata1 and *.ibd files in different directories. - Bayesian Filter detected spam

2005-12-20 Thread Gordon Bruce
The following takes a little effort, but it should get you close to dump file size. On 5.0.x you can use Information_schema.columns to get average row length for MyISAM tables. Take that plus the punctutation {~35 + 3* # cols for insert per row if you enclose your columns in "'s} in the insert sta

Is this a MySQL 5.0.x bug OR What am I missing?

2005-12-23 Thread Gordon Bruce
er_Create | +-+-+-+-+--+--+---+----+++-+--+-

RE: Changing types on the fly in select queries?

2005-12-27 Thread Gordon Bruce
Generally MySQL does format conversion for you to match data types. You can also force the CONCAT result to be integer by the following where concat(year,period,week) + 0 < 2007031 ^^^ -Original Message- From: Jay Paulson (CE CEN) [mailto:[EMAIL PROTECTED]

  1   2   >