RE: if else statement
Hi Peter, SELECT IF(col1=3, (Select col2 from table2 where table2.id = 1), (Select col2 from table3 where table3.id = 1)) FROM table1 WHERE id=1; Thanks you for you answers. Can I put SELECT statements inside the IF statement? Mysql give error ERROR 1064: Error in SQL syntax. Under Control Flow functions of the manual, it says IF(expr1,expr2,expr3) If expr1 is TRUE (expr1 0 and expr1 NULL) then IF() returns expr2, else it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used. But doesn't say what expr is. Examples only show numeric and string functions. -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 21, 2006 4:43 PM To: [EMAIL PROTECTED]; Song Ken Vern-E11804 Cc: mysql@lists.mysql.com Subject: RE: if else statement SELECT IF(col1=3, (Select col2 from table2 where table2.id = 1), (Select col2 from table3 where table3.id = 1)) FROM table1 WHERE id=1; That should do it. -Original Message- From: Thomas Lundström [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 21, 2006 7:51 PM To: Song Ken Vern-E11804 Cc: mysql@lists.mysql.com Subject: Re: if else statement Not sure what you're aming for here and how your data is structured but why not use a join and alias and fetch all info in one select and then solve what you need in your code? Something in the line of: select t2.col2 from_t2, t3.col2 from_t3 from table1 t1, table2 t2, table3 t3 where t1.id = t2.id and t1.id = t3.id and t1.id = 3 Maybe you can do something like that? Regards, Thomas L. ons 2006-06-21 klockan 17:16 +0800 skrev Song Ken Vern-E11804: Hi, I'm trying to build a query in using SQL instead of doing it in Perl. I am trying to do something like this : If ((select col1 from table1 where id = 1) == 3) Then Select col2 from table2 where table2.id = 1; Else Select col2 from table3 where table3.id = 1; In Perl I would probably do have to access the DB twice. Select col2 from table1 where if = 1; If (col2 == 3) { Select col2 from table2 where table2.id = 1; } else { Select col2 from table3 where table3.id = 1; } I've read the manual on subqueries but the example don't indicate how I can do a conditional test using a subquery? Am I on the right track or is there another way to do this? Thanks -- Ken e11804 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
if else statement
Hi, I'm trying to build a query in using SQL instead of doing it in Perl. I am trying to do something like this : If ((select col1 from table1 where id = 1) == 3) Then Select col2 from table2 where table2.id = 1; Else Select col2 from table3 where table3.id = 1; In Perl I would probably do have to access the DB twice. Select col2 from table1 where if = 1; If (col2 == 3) { Select col2 from table2 where table2.id = 1; } else { Select col2 from table3 where table3.id = 1; } I've read the manual on subqueries but the example don't indicate how I can do a conditional test using a subquery? Am I on the right track or is there another way to do this? Thanks -- Ken e11804 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
mysqlcc temp table created for queries
Hi, I am using mysqlcc 0.9.4-beta to browse my DB. Server side am using 5.0.18-nt. However, when I try to double click on a table to see the data, it will always return the error. [localhost] ERROR 1146: Table 'test.1' doesn't exist The SQL query for this is SELECT * FROM `test` The query is still sucessful but I would like to know what causes this error. However, when I try to browse another server running 4.1.10-nt, double clicking produces no such error. Setup is similiar to the above. It seems like different version are doing things differently. Looking through the newsgroups forums, I understand that that mysql5.0 will prepend the tablename to each column. But I don't understand what does 'test.1' refer to. Can anyone help explain? Thank you. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Table grows much faster than others.
Hi, I have one table which grows at a much faster rate than the rest. It has 80 times more entries than the second largest table, which has 10k rows. What are the steps I can take to slow down the growth? Can I partition the table? Will the size of the table affect the perfomance of queries? I am running mysql 4.018 on win2k. Please CC replies to me as I'm not subscribed to the list. Thanks. -- [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Error when reading back dump file.
Hi, I am using the cygwin version of the mysql client. When trying to read back my dump file into the database, I get this error [EMAIL PROTECTED]:/cygdrive/c/Program Files/mysql/data 23:15$ ../bin/mysql.exe -h 10.224.3.3 -u root -p testdb -e ./zztest.sql Enter password: ERROR 1064 at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near './zztest.sql' at line 1 The file I am trying to read back contains the first few lines :- -- MySQL dump 10.7 -- -- Host: localhostDatabase: test_irt -- -- -- Server version 4.1.3b-beta-nt-log /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */; -- -- Table structure for table `tasklist` -- CREATE TABLE `tasklist` ( `id` int(10) unsigned NOT NULL auto_increment, `coreid` varchar(100) NOT NULL default '', `amtext` longtext NOT NULL, `amcolor` varchar(100) NOT NULL default '', `pmtext` longtext NOT NULL, `pmcolor` varchar(100) NOT NULL default '', `date` date NOT NULL default '-00-00', PRIMARY KEY (`id`,`coreid`,`date`) ); -- -- Dumping data for table `tasklist` -- INSERT INTO `tasklist` VALUES (67,'user','test','','test','','2004-12-22'); --- However when I log into client and issue :- mysql source ./zztest_irt.sql; Query OK, 0 rows affected (0.00 sec) it seem to work fine. Is there a syntax error when running the command? Thanx, Ken -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]