Constants required in String functions?

2003-06-03 Thread Hu Qinan
Dear all, I am wondering whether constant arguments are required in string functions, e.g. Substring(str, pos, len). Given MyTable: ... MyString TEXT,(muti-byte characters) MyPos UNSIGNED(10), MyLength UNSIGNED(10). While (1) wor

embedded group function

2003-03-25 Thread Hu Qinan
All, I tried to use SELECT MAX(COUNT(*)) FROM ... GROUP BY ... in MySQL. But an error occured: Invalid use of group function. Is it necessary to create a temporary table to store the COUNT(*) results, and then get the MAX from it?

group by quesion?

2003-03-24 Thread Hu Qinan
How to write this sql? I have a table: Date |Low High -- ... 28 |17 - 29 |17 29 |23 29 |410 30 |17 30 |2

Fw: problem about bulk insertion

2003-03-18 Thread Hu Qinan
Dear all, I intend to write a large volume of records to a table tbl. tbl: fld1, int unsigned not null auto_increment primary key, fld2, text fld3, text The combination of (fld2, fld3) should be be unique, so I need to check for duplicates every time when a record is added. -->Question1: How

Update to one of three values.

2003-03-14 Thread Hu Qinan
A table T contains two fields: T.ID, T.Data. I want to set its T.Data to one of three values: NULL, 0, 1 according to its T.ID. This is what I have done: 1. Set all Data to be NULL: UPDATE T SET Data = NULL; 2. Create a temporary table Temp to store some selected T.ID. Then update the Data of

Update query with Join

2003-03-10 Thread Hu Qinan
I use MySQL 3.23.

Update query with Join

2003-03-10 Thread Hu Qinan
Dear all, Which records in tbl1 are to be updated are determined by an INNER JOIN with tbl2. I have tried the following: UPDATE tbl1 INNER JOIN tbl2 ON tbl1.id = tbl2.id SET tbl1.col1 = 0; UPDATE tbl1, tbl2 SET tbl1.col1 = 0 WHERE tbl1.id = tbl2.id; UPDATE tbl1 SET tbl1.col1 = 0 INNER JOIN tb

select rows based on the results from another query

2003-03-09 Thread Hu Qinan
Dear all, I intend to write a query to select rows based on the results from another query: SELECT * FROM tbl1 WHERE coln1 IN (SELECT DISTINCT coln2 FROM tbl2); But this one does not work in MySQL. Anyone could help me to figure out this problem? Thanks a lot.

alias a select query

2003-03-09 Thread Hu Qinan
Dear all, A table "book" looks like this: "page" "content" -- 1 abc 1 de 2 fgh 3 ijk 3 lmn 3 opq ... 210 z I need a query to randomly select 90% of all pages and their corresponding contents. I have written the following querys. But I have pr