Re: Joins on tables with funky data?

2005-12-12 Thread Roger Baklund
Subscriptions aka Jenifer wrote: query: SELECT tblCustomer.*, tblNotes.note FROM tblCustomer LEFT JOIN tblNotes ON tblCustomer.customerid = tblNotes.noteID WHERE tblCustomer.customerid = 123 You are joining the customerid from the customer table to the noteID from your notes table. You should

Re: dynamic fieldname to assign to

2005-11-17 Thread Roger Baklund
C.R.Vegelin wrote: Hi All, I have a "simple" problem and hope you can help me. I have an input table Updates with various fields, incl. Month and MonthlyValue. The field Updates.Month ranges from 1 to 12. I also have a target Data table with 12 fields, called Jan, Feb, Mar, ... `Dec`. Depending o

Re: timing queries?

2005-10-01 Thread Roger Baklund
Jacek Becla wrote: Hi, Does anyone know how to execute SQL statements from a text file such that the summaries "X rows in set (X.YZ sec)" are printed for each query? Neither of these do it: mysql < batch-file mysql -e 'source batch-file' If you add verbosity using the parameter -vv (or -v

Re: possible MySQL bug - insert into 'double' column problem with mysql 4.1

2005-09-19 Thread Roger Baklund
Andrew Braithwaite wrote: Hi All, I have a strange error when trying to insert into a table with 2 'double' fields. It inserts into the 1st field OK but fills the 2nd one with nines. See below for a complete recreate. [...] | lon | double(7,6) | YES | MUL | NULL|

Re: 1064 error

2005-09-18 Thread Roger Baklund
Schalk Neethling wrote: Greetings What might be causing the 1064 error in the following query? SELECT mem_number, first_name, last_name, area_represented, joining_points + E-Model Challenge + SA Pro Model + Star Model Challenge + Eastern Cape Classic + SA Model Super Star + KZN Model GP + Mpum

Re: Yet another null question

2005-09-18 Thread Roger Baklund
[EMAIL PROTECTED] wrote: I did not expect that null was not not-equal to 1. Any comparison with NULL returns NULL: mysql> select null<>1,null>1,null<1,null=1; +-++++ | null<>1 | null>1 | null<1 | null=1 | +-++++ |NULL | NULL

Re: Unable to Edit Table Data

2005-09-11 Thread Roger Baklund
Chris Spencer wrote: I'm on Fedora Core 4. When I right-click on a table in Mysql-administrator and choose "Edit table data" nothing happens, and I get this in the console: (mysql-administrator-bin:4628): glibmm-CRITICAL **: unhandled exception (type Glib::Error) in signal handler: domain: g-e

Re: HTML in MySQL?

2005-09-11 Thread Roger Baklund
Vladimir B. Tsarkov wrote: After the execution of the script: we will get: 1 and no empty lines. If you want to output the same data, that was written using a textarea field of a form, you should use the "" tag. In one word: kiss. Converting the data before inserting it in the database,

Re: need help with foreign keys, new to mysql

2005-08-24 Thread Roger Baklund
Pat Adams wrote: On Wed, 2005-08-24 at 06:11 -0500, John Gonzales wrote: CREATE TABLE `journal` ( `journal_id` int(10) unsigned NOT NULL auto_increment, [snip] CREATE TABLE comments ( comment_id INT, comment_journal_id INT, INDEX jrn_id (journal_id), Here you are defining an index name

Re: getting started with mysql:

2005-08-24 Thread Roger Baklund
Sérgio Júnior wrote: > I’ve never worked with mysql db’s and I would like to start a new > Project at work creating a new mysql db. I start read but I got lost > so many times that I am seeking guidance help, someon to tell me > first start with this and after do that. Is anyone available to give

Re: Question on Join

2005-08-15 Thread Roger Baklund
Manoj wrote: Dear All, I am trying to join two tables say a & b. Both tables have a set of dates. I want to join the tables in such a fashion that I retrieve all dates from table A. If table b has corresponding data (for that date) then it will display it or else will display null. I am prett

Re: convert varchar to char

2005-08-13 Thread Roger Baklund
Pooly wrote: Hi, I try to convert a varchar to a char, but it doesn't seems to work. From the manual: "...all CHAR columns longer than three characters are changed to VARCHAR columns." http://dev.mysql.com/doc/mysql/en/silent-column-changes.html > -- Roger -- MySQL General Mailing List F

Re: alter table - add a column

2005-06-14 Thread Roger Baklund
* Rhino: > You'll need three alter statements: > - one to add the new column > - one to get rid of the old primary key > - one to set the new column as the primary key In addition to adding the new column, there will be neccessary to populate the column with unique values. A primary key must allwa

Re: Inner workings of a JOIN

2005-05-27 Thread Roger Baklund
James Tu wrote: What does MySQL do internally when you perform a LEFT JOIN? You can read about it here: http://dev.mysql.com/doc/mysql/en/left-join-optimization.html > If you need more details, you could read the source... Let's say you have two tables: Table A has 1,000,000 rows Table B ha

Re: Query performance...two table design options

2005-05-27 Thread Roger Baklund
James Tu wrote: Hi: Let's say I want to store the following information. Unique ID - INT(10) autoincrement First Name - VARCHAR (25) Last Name - VARCHAR (25) Age - INT(3) In general 'age' is a bad column, because you need to know what year the data was entered to calculate the current age. I

Re: Remove 1st 3 Chars

2005-05-11 Thread Roger Baklund
Andrew Braithwaite wrote: Is there any way to get MySQL to return the results of this query with the 'fieldname' in the order listed in the in() bit? select fieldname from tablename where fieldname in ('B4079','B4076','B4069','B4041','A4710','58282','58220','56751','56728' ,'45003','09234','04200',

Re: 1 table or 2?

2005-05-11 Thread Roger Baklund
Dave Shariff Yadallee wrote: I am trying to set up a chem structures table. column 1 is the key, column 2 is the description, column 3 is the structure which is a blob. In PHP the first 2 columns comes out as text as expected, but the 3rd I am trying to tell PHP please ignore this initially since t

Re: Solution to slow queries

2005-05-11 Thread Roger Baklund
Paul Halliday wrote: srcaddr VARCHAR(15), dstaddr VARCHAR(15), Are these ip-adresses? If they are, consider using UNSIGNED INT columns and the INET_NTOA() and INET_ATON() funtions. It will save you a lot of space, thus increase the amount of data your hw can handle. They are indeed i

Re: Solution to slow queries

2005-05-10 Thread Roger Baklund
Paul Halliday wrote: srcaddr VARCHAR(15), dstaddr VARCHAR(15), Are these ip-adresses? If they are, consider using UNSIGNED INT columns and the INET_NTOA() and INET_ATON() funtions. It will save you a lot of space, thus increase the amount of data your hw can handle. I have read u

Re: Sorting by relevance?

2005-05-09 Thread Roger Baklund
Erik Bukakis wrote: I just learned a lot stuff at http://dev.mysql.com/doc/mysql/en/sorting-rows.html including sorting by number-to-text, text-to-number, names, specific values, etc. However, the document didn't mention on how to sort by relevance. For instance, someone search for "Ang": COLUMN

Re: How to extract only the first few lines from a longtext field

2005-05-09 Thread Roger Baklund
symbulos wrote: how do you extract with a query only the first few lines from a blob field? For instance: you have an article stored in the field. You would like to visualise the first few lines before reading it all. You could use the LEFT() function to return for instance the 200 first characte

Re: Simple query? Is it possible?

2005-05-09 Thread Roger Baklund
Vaidas Zilionis wrote: [...] Example items are displayed 100 in page, and i display 20 pages numbers 1 ... 4[5] 6 x doomain.con/items.php?page=5 and i get all result here with limit 400,100 Yes, with PHP it would be something like this: $items_per_page = 100; $limit_clause = ((int)$page-1)*$ite

Re: SELECT DISTINCT ROW(A,B) ?

2005-05-07 Thread Roger Baklund
Dan Bolser wrote: SELECT DISTINCT ROW(A,B) from a; While I am on a roll (of sorts) can I ask if the above syntax should be valid or not? If you mean the exact syntax above, I think not... it looks like ROW() is a function taking two parameters in this case... what does the function return? Is it

Re: Query Problem

2005-04-21 Thread Roger Baklund
Dto. Sistemas de Unitel wrote: You don't understand me, I refer that if in a table I use productos.prod_id and in other table indexes.id if I can use this two fields like the same index, because when I named the two equal, the index start to work fine. There should be no problem with joining two ta

Re: Query Problem

2005-04-21 Thread Roger Baklund
Dto. Sistemas de Unitel wrote: Hi Roger, You are ok, there was an index problem in one table, they name of the rows wasn't equal and MySQL didn't recognize they as the same index. I have changed the row name and now is working fine, but I have a little question, How can I use indexes with different

Re: Query Problem

2005-04-20 Thread Roger Baklund
Dto. Sistemas de Unitel wrote: Hi Roger, That was just I need. The order isn’t like you say: ++-+---++---+-+- ++---+-+ | id | select_type | table | type | possible_k

Re: Query problem

2005-04-20 Thread Roger Baklund
Dto. Sistemas de Unitel wrote: [...] something like /indexes.id=productos.prod_id and indexes.id_termino=terminos.id_termino and termino="computer" and termino=”intel”/ I know that is impossible, but maybe there is another way to make that). Yes, there is another way. You _can_ join the same tab

Re: SQL_BIG_RESULT

2005-04-14 Thread Roger Baklund
Yemi Obembe wrote: learnt SQL_BIG_RESULT in the select syntax builds a temporary table on the result (if I'm right). What will the Select statement to access such temporary table look like? This is an internal temporary table, the result is returned in the normal way, and the temporary table is de

Re: Index table query structure

2005-04-14 Thread Roger Baklund
Yemi Obembe wrote: If for example I have a table with the 3 columns: name,age,sex & I build an index table "index table" ? There is no such thing. on the column 'name'. how can i get result of the other rows (i.e age and) other rows? You mean other columns? from the main table What main tabl

Re: LEFT JOINS same data twice?

2005-04-13 Thread Roger Baklund
Chris Knipe wrote: Hi, Is it possible to left join the same data twice? Yes. TBL ONE: LocationID Location, varchar(100) TBL TWO: DepartureID, ArrivalID, Time SELECT tlb1.DepartureLocation AS Departure, tbl1.DepartureLocation AS Destination LEFT JOIN DepartureLocation ON tlb2.DepartureID=tlb1.Lo

Re: Weird Query Result

2005-04-05 Thread Roger Baklund
Mattias Håkansson wrote: Hello, I'm using MySQL 4.0.20 on Linux and I am experiencing some problems with a query result. I have the following table structure: mysql> desc gen_Lloyds_vessel; +-+--+--+-+-++ | Field | Type

Re: How to add 2 columns to a table with "After ColName"???

2005-03-15 Thread Roger Baklund
mos wrote: I've tried just about every syntax combination to try and add columns to a table using Alter Table and I keep running into syntax errors. Alter table MyTable add (newcol1 float after col3, newcol2 float after col3); or Alter table MyTable add (newcol1 float, newcol2 float) after col3

Re: insert data

2005-03-04 Thread Roger Baklund
Gerald Preston wrote: [...] I get "DBI connect<'club','gjwpp88',..> failed; Client does not support authentication protocol requested by server" Check this: http://dev.mysql.com/doc/mysql/en/old-client.html > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To

Re: # Seconds between two datetime fields

2005-03-03 Thread Roger Baklund
Brian Erickson wrote: We have a table that has two datetime fields (start_time and end_time). We'd like to be able to calculate the number of seconds between these two fields in a query. However, a simple "end_time - start_time" does not yield a correct result. SELECT start_time, end_time, end_time

Re: nested aliases in select

2005-02-26 Thread Roger Baklund
David Smithson wrote: Hi all. Can somebody explain to me why the following SELECT doesn't work?: SELECT COUNT(DISTINCT(CONCAT(contact_firstname,' ',contact_lastname) as contact_name)) as count FROM Contacts GROUP BY contact_ident ORDER BY contact_name; The error returned is: ERROR 1064: You have a

Re: xml import

2005-02-26 Thread Roger Baklund
Patrick Marquetecken wrote: I seems not to figure out how to import a xml file into mysql 4.x I'm working on, Linux, help would he fine. XML is an hierarchical format, it does not map directly to a relational database, which has a tabular format. I don't know if there are any general purpose tool

Re: Regular Expression Query

2005-02-26 Thread Roger Baklund
Scott Klarenbach wrote: I have a client that wants to search table fields for strings, and ignore any-non alphanumeric character in the field. (match only the alphanumeric portion of the field, and discard the rest) for example, a search for apple would return true on the following record a**__-p p

Re: Date Functions in MySQL

2005-02-23 Thread Roger Baklund
Clarence wrote: I have a log table that records certain transactions on one of my sites. I'm using a timestamp field to mark the date/time of each transaction. I'm trying to run a query that will display the transactions by date using the following SQL: SELECT COUNT(log_id) AS total, WEEK(FROM_UN

Re: Selecting with a list of keys

2005-02-23 Thread Roger Baklund
Tim Johnson wrote: I would like to construct a query that searces on a variable list of primary keys. Example: Lkeys = [12, 23, 15, 17]## python - style list of integers Select column from table where ID in Lkeys; ## mysql statement? Is this possible, or does one have to generate a quer

Re: compare dates

2005-02-18 Thread Roger Baklund
Reinhart Viane wrote: Concerning datetime type: Eg. in a forum if someone posts a message the date and the time is stored and shown of that message. I suppose they use timestamp in that case? They could, but because of the 'magic' behaviour of TIMESTAMP a DATETIME is often used. To conserve space,

Re: select case consider the first field only, MySQL 4.0.18

2005-02-18 Thread Roger Baklund
Jan Bartholdy wrote: Thanks Roger, but it does not work: SELECT CASE when Species_1_e > 0 THEN 'extern' when Species_3_e > 0 THEN 'intern' ELSE '' END AS `species_1_l` from species where statsample=1820; --Gives at a result 'extern' What is the value o

Re: select case consider the first field only, MySQL 4.18

2005-02-18 Thread Roger Baklund
Jan Bartholdy wrote: Dear List, I have a select case question SELECT CASE WHEN `Species_1_l` > 0 THEN 'intern' when 'Species_3_e' > 0 'Species_3_e' is surrounded by single quotes, not backticks... thus it is treated as a string, numeric value is 0, which is never > 0. BTW, th

Re: compare dates

2005-02-18 Thread Roger Baklund
Gabriel PREDA wrote: Let me assure you that DATETIME is the worst choice ever... because it need 8 bytes per record... TIMESTAMP uses only 4 ...but TIMESTAMP has a special behaviour which may not be wanted in all cases: the first TIMESTAMP column of a table is updated automatically when _any_ col

Re: Subquery problems

2005-02-17 Thread Roger Baklund
Roger Baklund wrote: Try something like this: SELECT ID,NAME,COUNT(*) FROM tableA LEFT JOIN tableB ON tableA.ID = tableB.ID GROUP BY ID,NAME Nope, sorry, that won't work, ID exists in both tables thus it must be prefixed with table name or alias: SELECT tableA.ID,... GROUP BY tabl

Re: Subquery problems

2005-02-17 Thread Roger Baklund
Joppe A wrote: hello all, I am a newbe working with MySQL. I have a problem that I can't figure out how to do. I have 2 tables that I want to take out data from, the tables looks like below. tableA == ID VARCHAR(12) NAMEVARCHAR(255) CREATED TIMESTAMP tableB ==

Re: how to make question that check the last hour

2005-02-16 Thread Roger Baklund
Jesper Andersson wrote: [...] created =VARCHAR(14) [...] select CREATED from SUBSCRIBER where date_sub(now(), interval 1 hour) <= created; What do I wrong?? The 'created' column is a normal string, the date_sub() function returns a "time string", i.e. a string on the special format "-MM-DD H

Re: Tricky Join with Animal-DB

2005-02-16 Thread Roger Baklund
Martin Rytz wrote: [...] With which join can I show the animals with all pics for this animal (even if there are more than one pic for an animal)? SELECT animal,pic FROM animal_pic,animal,pic WHERE animal.id = animalid AND pic.id = picid This will list all animals which have pictures, w

Re: Comparing bug in 4.1.7

2005-02-06 Thread Roger Baklund
Arjen Lentz wrote: [...] While we're at it: the term "non-zero"... what does it mean? As we all know, NULL != 0, and 0 == zero, consequently NULL must be non-zero. Flawed logic. Yes, I used flawed logic to illustrate my point: "non-zero" is a bad term to use in this context. The text from the

Re: Best way to store numeric data?

2005-02-02 Thread Roger Baklund
Keith Ivey wrote: Roger Baklund wrote: Galen wrote: I've got a huge table going, and it's storing a load of numeric data. Basically, a percentage or single digit rank, one or two digits before the decimal and fifteen after, like this: 6.984789027653891 39.484789039053891 [snip] You

Re: Best way to store numeric data?

2005-02-02 Thread Roger Baklund
Michael Dykman wrote: [...] The MySQL implementation also supports this optional precision specification, but the precision value is used only to determine storage size. Right. This means you can not have 15 decimals precision using DOUBLE: mysql> use test Database changed mysql> create table dtest

Re: Best way to store numeric data?

2005-02-02 Thread Roger Baklund
Galen wrote: I've got a huge table going, and it's storing a load of numeric data. Basically, a percentage or single digit rank, one or two digits before the decimal and fifteen after, like this: 6.984789027653891 39.484789039053891 What is the most efficient way to store these values? I will be

Re: SQL syntax error: help a noob

2005-01-31 Thread Roger Baklund
Chris Kavanagh wrote: My ColdFusion server tells me I have an error in my query syntax, but I can't work out what it is - because I'm working with code that someone very kindly gave me and I only have a vague idea of what the first line's doing! Can anyone see the problem here? SELECT DATEDIFF

Re: Need a query to get the difference of two tables

2005-01-31 Thread Roger Baklund
Harish wrote: Hi All, This query worked for me. SELECT a.address FROM a LEFT JOIN b ON a.id != b.iid AND b.message='y' Strange... that query should give far too many and wrong rows as a result, and it would take a long time to run on a big dataset... you are joining each row in table a with

Re: Need a query to get the difference of two tables

2005-01-31 Thread Roger Baklund
Michael Stassen wrote: Roger Baklund wrote: [...] select a.address from a left join b on b.iid=a.id where b.iid is null; That's not equivalent, because it leaves out a condition. I think it should be SELECT a.address FROM a LEFT JOIN b ON a.id = b.iid AND b.message='

Re: Need a query to get the difference of two tables

2005-01-30 Thread Roger Baklund
Harish wrote: Hi, I apprecaite anybody replying me with an equvalent query for this: I am using mysql 4.0.21 select a.address from a where a.id not in (select b.iid from b where b.message='y') This can be done with a left join: select a.address from a left join b on b.iid=a.id where b.iid is

Re: Listing all connected users?

2005-01-18 Thread Roger Baklund
sol beach wrote: How do I see who is currently connected to MYSQL & from where they originate? Use the SHOW PROCESSLIST command: http://dev.mysql.com/doc/mysql/en/SHOW_PROCESSLIST.html > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http:

Re: get field name

2005-01-18 Thread Roger Baklund
Chenri wrote: how do i get field name from this table Time Stat1 Stat2 Stat3 0905 1 1 1 0906 1 0 1 i want to get the field name Stat1 & Stat 3 from the 0906 row which have 1 as value I expect the result to be STAT1 STAT3 This is not easily done, if I understand you cor

Re: SHOW COLUMNS Syntax Using 3.23.54 Please!

2005-01-18 Thread Roger Baklund
shaun thornburgh wrote: I am trying to get all field names from my table that begin with letter X or Y, however the following statement and many variations I have tried produce an error: SHOW COLUMNS FROM TABLE LIKE "X%" OR LIKE "Y%" According to the manual, the pattern for SHOW COLUMNS is: SHOW

Re: select & count

2005-01-13 Thread Roger Baklund
Jerry Swanson wrote: [...] I need to get count of received, count of send and cound of cancelled records. I know that I can do this in 3 queries. #1. select count(*) from account where status='received'; #2. select count(*) from account where status='send'; #3. select count(*) from account where s

BEGIN...nothing? (Re: Update log)

2005-01-06 Thread Roger Baklund
Chenri J wrote: one more question, how about when i'm using 'BEGIN' and doesn't end it with 'COMMIT' neither 'ROLLBACK' what will happen. I've tried before and nothing happen but does anyone have an opinion? This depends on a number of things: If the table handler in question does not support tra

Re: Update log

2005-01-06 Thread Roger Baklund
Chenri J wrote: i'm still using 3.23 can anyone show me how to activate update log by modifying the my.cnf/ my.ini Show you? It is not clear what you want. Do you need help starting the editor? What OS are you using? On Windows systems Notepad can be used to edit the configuration files. Which 3

Re: adding automatic alert

2005-01-06 Thread Roger Baklund
Aji Andri wrote: Hi all, I'm make an inventory goods database, in one of my table I need to make an automatic alert when my stock reach it's limit (say for tires it's limit is 4), can I make an automatic alert for it so when it reach it limit I can have an alert may be a beep ? This is a typical t

Re: Query Help, Two Tables...

2004-12-24 Thread Roger Baklund
Jason Caldwell wrote: Hi I have two tables; tbl_Headers and tbl_SubItems. tbl_Headers contain my Header Items such as (fields: ID & HEADER) ID HEADER --- 1.00 TOPIC ONE 2.00 TOPIC TWO 3.00 TOPIC THREE tbl_SubItems contain Sub Header Items such as (fields: ID & SUBITEM)

Re: Quick Question: Year() function result?

2004-12-17 Thread Roger Baklund
Rhino wrote: Does anyone know what Column Type the result of the Year() function is? In other words, if I execute: select Year(Hiredate) as mycolname from mytable; is the result a smallint? a char()? a varchar()? Unfortunately, the manual doesn't say and I can't think of a quick way to figure it ou

Re: Strange results - Part 2

2004-12-13 Thread Roger Baklund
Steve Grosz wrote: This is a follow up message to a earlier threat this week (which is included in the message below) "model","CREATE TABLE `model` ( PRIMARY KEY (`PID`) "vendor","CREATE TABLE `vendor` ( PRIMARY KEY (`PID`) "specs","CREATE TABLE `specs` ( PRIMARY KEY (`SpecID`) Like Rhi

Re: Epoch seconds

2004-12-13 Thread Roger Baklund
John Berman wrote: I have a table that has start_date and expire_date in the format: 2004-12-31 That is an output format... yes? If the column is a string type (char/varchar/text...), you should change it to a DATE type, or maybe TIMESTAMP. The default output format for DATE type columns is -

Re: Deleting redundant rows

2004-12-13 Thread Roger Baklund
Walter Pucko wrote: Hello there, I do have a table in mysql 4.x with redundant info. Only the autoincrement ID is different. Example: ID citycc 2559756 Witkop SF 2559757 Witkop SF This turns to be a huge problem since I cant find a way to delete the redundant rows with a mysql query.

Re: Strange results - Part 2

2004-12-13 Thread Roger Baklund
Roger Baklund wrote: [...] You are joining the model table on vendor.PID=model.VendorID, and model.VendorID is not a primary or unique key, it could contain duplicates. ... probably the four rows you want. This is ok. It's probably the other join that causes the problem. -- Roger --

Re: copy2diffdatabase

2004-12-09 Thread Roger Baklund
N. Kavithashree wrote: hello, i hv a database ONE with some 10 tables; i want to have a backup so how can i copy these tales to another database in the same server and also to any other server? The mysqldump utility can be used for this kind of things: http://dev.mysql.com/doc/mysql/en/mysqldump.ht

Re: selection

2004-12-09 Thread Roger Baklund
N. Kavithashree wrote: when i retrieve records using follwg query : select * from table where country='United States' and code='US'; Is the value if the country field "United States"? Or is it "United States of America" or similar? But if i give :s select * from table where country like 'United S

Re: Truncating trailing blanks of a constant

2004-12-09 Thread Roger Baklund
Thomas Spahni wrote: Hi everyone, recently I encountered the following problem: SELECT COUNT(id) FROM sometable WHERE somevarchar LIKE 'thistext '; returned 0 (of course!) because trailing blanks can't exist in a column of type VARCHAR. But: Shouldn't the constant be truncated automatically in this

Re: Use of limit with IN on subquery

2004-12-03 Thread Roger Baklund
[EMAIL PROTECTED] wrote: What if we used the MySQL-specific feature "group-wise auto_increment" ? I was thinking of a similar idea, with user variables, also MySQL-specific. What do y'all think? I think it should work, but only Rick can tell... :) -- Roger -- MySQL General Mailing List For list arc

Re: Use of limit with IN on subquery

2004-12-03 Thread Roger Baklund
Michael Stassen wrote: Michael Stassen wrote: Don't bother. This is a very expensive solution. You get nearly a Cartesian product on each JOIN. I've got a 40 row test table with 20 values in each of 2 groups. The top 3 version of this examines 2302 rows to produce the 3 values for each of th

Re: sum queries

2004-12-03 Thread Roger Baklund
James Nunnerley wrote: * Roger Baklund: select date_format(ts,"%Y-%m-%d %H") period,sum(rcvd),sum(sent) from mytable group by period; So the below query above will allow me to group by hour - which is quite useful - is there anyway of grouping by say 3 hour periods? Not using the d

Re: sum queries

2004-12-03 Thread Roger Baklund
James Nunnerley wrote: I'm trying to create a table, and ultimately a graph, out of some syslog data. I have a table with the following info in it: Time (unixtime stamp), bytes rcvd and bytes sent I want to create a sql statement that group the data over a certain period of time, and produces

Re: Use of limit with IN on subquery

2004-12-03 Thread Roger Baklund
Rick Robinson wrote: I'm using MySQL 4.1.7, trying to do a subquery that's apparently unsupported - I'm hoping someone can provide a quick alternative for me. I have a simple table Z with 3 columns, k1, k2, and total_amt, where k1 and k2 make up the primary key. I want to create a report that li

Re: Use of limit with IN on subquery

2004-12-03 Thread Roger Baklund
Rick Robinson wrote: Hi all- I'm using MySQL 4.1.7, trying to do a subquery that's apparently unsupported - I'm hoping someone can provide a quick alternative for me. I have a simple table Z with 3 columns, k1, k2, and total_amt, where k1 and k2 make up the primary key. I want to create a report

Re: Column type question ?

2004-12-03 Thread Roger Baklund
TAG wrote: I have an application that reads files converts them and then inserts them into a database. It has 2 columns that I need help with. First is the OFFSET column - this stores the datafile offset .. In C it is a UNSIGNED LONG and looks like : 0x2528 the second colun is a CRC for the f

Re: Comparing bug in 4.1.7

2004-12-02 Thread Roger Baklund
Michael Stassen wrote: You are overthinking the issue. Probably. :) mysql> SELECT VERSION(); +---+ | VERSION() | +---+ | 4.1.7 | +---+ 1 row in set (0.00 sec) mysql> SELECT 1 OR NULL; +---+ | 1 OR NULL | +---+ | 1 | +---+ 1 row in set (0.0

Re: Comparing bug in 4.1.7

2004-12-02 Thread Roger Baklund
Vlad Shalnev wrote: * from the manual: >> Logical OR. Evaluates to 1 if any operand is non-zero, to NULL if any >> operand is NULL, otherwise 0 is returned. * Roger Baklund: This definition (from the manual) is self-contradicting: 1 OR NULL should evaluate to 1 because "any op

Re: Comparing bug in 4.1.7

2004-12-02 Thread Roger Baklund
Vlad Shalnev wrote: [...] OR || Logical OR. Evaluates to 1 if any operand is non-zero, to NULL if any operand is NULL, otherwise 0 is returned. This definition (from the manual) is self-contradicting: 1 OR NULL should evaluate to 1 because "any operand is non-zero", but it should also evaluate t

Re: Indices and Constraints.

2004-12-02 Thread Roger Baklund
[EMAIL PROTECTED] wrote: Hi, Thank you. But I want select the constraints and indices used on the table. How can we get this information?. Please help me in this. Ian gave you the answer: From: Ian Sales [...] - show indexes from DATABASE_NAME.TABLE_NAME The syntax is: SHOW INDEX FROM tablenam

Re: Reg SubQuery

2004-12-02 Thread Roger Baklund
[EMAIL PROTECTED] wrote: Thanks for the reply. The main aim is to select the first record or the last record. Is there any direct command for these. Please help me in this. There is no first or last unless there is a sort order. To get the first row: select * from table order by col1 limit

Re: Weird query behaviour

2004-12-01 Thread Roger Baklund
Stuart Felenstein wrote: [...] But if in the where statment I add: where School = Columbia and School = Stamford Nothing is returned The WHERE clause describes EACH of the rows you get in the result. No one row can have a value in the School column equal to "Columbia" AND "Stamford" at the same

Re: Need help figuring out indexes for faster SELECT queries

2004-12-01 Thread Roger Baklund
Grant Giddens wrote: I have a new project I'm working for and I was wondering if anyone could help me optimize my selects for speed. I have a table with about 500,000 entries. The table structure I'm using is (via my PHP commands): $sql = "CREATE TABLE $store_data_table ( $store_dat

Re: Question: Limit search on string

2004-12-01 Thread Roger Baklund
Stuart Felenstein wrote: I'm storing telephone number (US) in 10 digit varchars. If I want to do a search on just the area code, is there a way to limit it to just the first 3 digits of the string ? I'm trying something like this but still getting back the whole string: select Telephone from Sign

Re: multi period sum() selects

2004-12-01 Thread Roger Baklund
Bgs wrote: [...] I have a db which has among others (including text fields) a timestamp field and a counter field. I want to make statistics from them, doing sum()s with conditions 'timestamp>P1 and timestampP2 and timestamp A trivial way would be to make a cycle for Pn but that takes a lot of

Re: converting to Innodb.

2004-12-01 Thread Roger Baklund
Fredrik Carlsson wrote: Hi list, I have a question regarding mysql and innodb. My current setup uses myisam and the db size is about 1.6 GB with two table that each have about 500k rows. I perform alot of fulltext search on these tables and they can sometimes take along time to finish and when t

Re: Reg SubQuery

2004-12-01 Thread Roger Baklund
Roger Baklund wrote: That leaves us with the answer from Gleb Paharenko, except the insert query should be "insert into memp select min(salary) from emp;" ... and the select should be: select emp.* from emp,memp where salary=m; He would get all employes with the lowest salary, as

Re: Reg SubQuery

2004-12-01 Thread Roger Baklund
[EMAIL PROTECTED] wrote: Or.. Select * from emp order by id asc limit 0,1 if you want to fetch all details. That was what I said, but lets take a closer look at what the original poster asked: "I need to get all the details of an employee whose salary is the lowest." Now, in his example he used

Re: Reg SubQuery

2004-12-01 Thread Roger Baklund
[EMAIL PROTECTED] wrote: I need to get all the details of an employee whose salary is the lowest. I can do like this in Oracle select * from emp where id = (select min(id) from emp). Can we have any alternative in MySQL for the above query, as sub queries are not supported in MySQL 4.0.21 There is

Re: Select member when it meets two requirements

2004-11-30 Thread Roger Baklund
Graham Cossey wrote: Am I missing something? Will this not do the trick: SELECT DISTINCT member_id FROM table WHERE specialty_id IN(6,33); That would return any member_id with specialty_id=6 and any member_id with specialty_id=33, i.e. member_ids with specialty_id 6 OR 33. I think he wanted membe

Re: update and concat

2004-11-30 Thread Roger Baklund
Thomas McDonough wrote: I'm trying to set all the values of column 'map' to the value of column ML and '.png'. My intuition and an extensive reading of the manual and mail archives tell me to do it like this: mysql> update listings set map= concat (ML, '.png') where ML<>''; but all I get is thi

Re: Changing sort order of items.

2004-11-29 Thread Roger Baklund
Michael J. Pawlowsky wrote: I'm trying to create the most efficient way to allow a user to change the display order of a group of rows in a table. Lets say the basic table is: id group_id name sort_order The query to display it would be "SELECT id, name FROM mytable WHERE group_id = $x ORDER BY s

Re: MIGRATION OF DATABASE FROM ONE BOX TO ANOTHER BOX

2004-09-24 Thread Roger Baklund
* Seena Blace > How to migrate mysql database from one box to another box ? You could use mysqldump on the source box, and the standard client to import the dumped file on the target box: http://dev.mysql.com/doc/mysql/en/mysqldump.html > There are other options, depending on the table handler u

Re: great problem with questions

2004-09-24 Thread Roger Baklund
* DeRyl > * Roger Baklund > The first thing to notice: "Using temporary"... this is to be avoided, if > possible. > > ## how is the correct way to avoid that? Depends, in this case I think it is because of the DISTINCT. > The first table read is klien

Re: great problem with questions

2004-09-23 Thread Roger Baklund
* DeRyl > explain example sql question gives: [...] The first thing to notice: "Using temporary"... this is to be avoided, if possible. The first table read is klientslowo based on the criteria klientslowo.klientslowo LIKE 'sam%'. Is this a reasonable approach to solving the query, giving your kn

Re: great problem with questions

2004-09-23 Thread Roger Baklund
* DeRyl > I have database with 30 tables [some have over 2000k some other > over 4000k rec] > > when I want to run a sql with a few conditions the answer is > dramatically slow > [over 70 seconds!] > sql-s with one condition usually works well.. > > how is the corrcet way to optimize the database

Re: SELECT question

2004-09-20 Thread Roger Baklund
* Andre Matos > I am performing a SELECT and I am getting 0 rows when I run the SELECT > direct in the MySQL database and getting 1 when I run using PHP. > This is my > select: > > SELECT * FROM scan WHERE TimePointID = 3 AND ScanQCResult = 'n' AND > (ScanStatusID < 90 OR ScanStatusID > 98); Looks

Re: Simple query question

2004-09-20 Thread Roger Baklund
* John Mistler > I have a table in which the first column is either 1 or 0. The second > column is a number between 0 and 59. I need to perform a query > that returns > entries where: > > 1. IF the first column is 1, the second column is NOT 0 > 2. IF the first column is 0, the second column i

  1   2   3   4   5   6   7   8   >