Re: How to use 'if' in select [solved]

2005-11-29 Thread Gobi
Thanks for everyone's input. Essentially, I summed up all the NEGs and non-NEGs in a view and then use the 'if' logic to filter out the numbers. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: How to use 'if' in select

2005-11-28 Thread Gobi
[EMAIL PROTECTED] wrote: Wouldn't it be just as simple to count all 'neg', 'pos', and 'ind' values for both columns? By the way, is there some other column you are grouping by or is it always going to apply to entire tables of information? I know this is not what you wanted. However, what you

Re: How to filter rows based on a value?

2005-11-28 Thread Gobi
sheeri kritzer wrote: You could do something similar to the following: set @a:=0; select 0 from Dummy where if(status="Pos",@a:=null,@a:[EMAIL PROTECTED]); select @a; Use the value of @a -- it will be null if there was ever a null value (because 1+NULL=NULL) and it will be the count if there

Re: How to use 'if' in select

2005-11-28 Thread Gobi
[EMAIL PROTECTED] wrote: Wouldn't it be just as simple to count all 'neg', 'pos', and 'ind' values for both columns? By the way, is there some other column you are grouping by or is it always going to apply to entire tables of information? I know this is not what you wanted. However, what you

Re: How to use 'if' in select

2005-11-28 Thread Gobi
Felix Geerinckx wrote: On 28/11/2005, Gobi wrote: I need to write a select clause based on the following conditions: If all rows of status1 == "Neg" count all "Neg" rows in status1 else check if all rows of status2 == "Neg" count all "Neg"

How to use 'if' in select

2005-11-28 Thread Gobi
I have not used an 'if' clause in select before but I think I may have a scenario which calls for it. I have a table with the following sample data: idx status1 status2 1"Neg""Neg" 2"Pos""Neg" 3"Neg"NULL 4"Ind""Neg" I need to write a select clause based on the

Re: Cannot get database connection

2005-11-23 Thread Gobi
Hassan Schroeder wrote: Gobi wrote: MySQL 5.0.15 and Tomcat 5.5.12. However, I cannot seem to get a connection object from my servlet and for the life of me, I can't figure out why. Here is what I have done: and I created the following servlet, TestSQL: It'

Re: Cannot get database connection

2005-11-23 Thread Gobi
Xiaobo Chen wrote: I am not sure if you're trying to connect from outside of your office newwork. If you try 'telnet' using 3306 (forgot the syntax, check the Mysql site)outside your office network and if you couldn't get through,(otherwise you will get some garbage characters) then you can't co

Re: Cannot get database connection

2005-11-23 Thread Gobi
Xiaobo Chen wrote: Have you tried to put the port 3306 after the host? I assume you are in the localhost. Yes, I am trying to connect in localhost. I did 'nmap localhost' and port 3306 is open and I can connect to mysqld with mysql client. I will try putting 3306 after the host when I get

How to filter rows based on a value?

2005-11-22 Thread Gobi
Suppose that I have a dummy table named, Dummy, and it has a column name Status, which can contain values Neg, or Pos. If I have the following data in table, Dummy: id, status 1 Neg 2 Neg 3 Pos 4 Neg I need to write a query returns the count of number of Neg in status but filters out

Cannot get database connection

2005-11-22 Thread Gobi
Not sure if this is the place to ask but hopefully someone can help me here. I am setting an application system and have successfully setup MySQL 5.0.15 and Tomcat 5.5.12. However, I cannot seem to get a connection object from my servlet and for the life of me, I can't figure out why. Here i

Re: Help with an SQL query

2005-11-06 Thread Gobi
Rhino wrote: I'm glad the explanation helped. I figured that the solution alone wouldn't be very useful if it wasn't explained since it is not obvious to most people how correlated queries work :-) I really wasn't trying to center you out with my "rant" about MySQL version. It's been a long-run

Re: Help with an SQL query

2005-11-05 Thread Gobi
Rhino wrote: I can't test this in MySQL- I'm using an older version of MySQL that doesn't support subqueries - but it works in DB2 and it should do the trick for getting the current weight of each VBS_id value: select VBS_id, date, weight from VBS_table x where date = (select max(date) from VBS

Re: How to select on passwords?

2005-11-04 Thread Gobi
Gobi wrote: I was using MySQL 4.1 and have a Users table where I store the UserID and the corresponding password using the following: Insert into Users (UserID, Password) values ('someid', password(somepw)); and when people login, I would query using: Select * from Users wh

How to select on passwords?

2005-11-04 Thread Gobi
I was using MySQL 4.1 and have a Users table where I store the UserID and the corresponding password using the following: Insert into Users (UserID, Password) values ('someid', password(somepw)); and when people login, I would query using: Select * from Users where UserID = 'someid' and Passwo

Re: Help with an SQL query

2005-11-04 Thread Gobi
Figured out the query: select idx, vbs_id, date, weight from Weight, (select vbs_id as maxid, max(date) as maxdate from Weight group by vbs_id) as t where vbs_id = maxid and date = maxdate; It returns the proper weight and idx. -- MySQL General Mailing List For list archives: http://lists.mys

Re: Help with an SQL query

2005-11-04 Thread Gobi
Johan Höök wrote: Hi Gobi, there was a similar posting in august. See: http://lists.mysql.com/mysql/187436 which I think describes what you want. I'll include a bit of it here as well -- This is out of the MySQL class and is called the Max-Concat

Re: Help with an SQL query

2005-11-04 Thread Gobi
Johan Höök wrote: Hi Gobi, there was a similar posting in august. See: http://lists.mysql.com/mysql/187436 which I think describes what you want. I'll include a bit of it here as well -- This is out of the MySQL class and is called the Max-Concat

Re: Help with an SQL query

2005-11-04 Thread Gobi
Gobi wrote: Arno Coetzee wrote: Gobi wrote: Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 4

Re: Help with an SQL query

2005-11-04 Thread Gobi
Arno Coetzee wrote: Gobi wrote: Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 41110/8/2005

Help with an SQL query

2005-11-04 Thread Gobi
Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 41110/8/200511.52 51210/8/2005

Re: Cannot start mysqld

2005-08-11 Thread Gobi
Never mind. I figured it out. I had to run the install_db script as mysql user. Gobi wrote: I find that I can start mysqld by using the "--skip-grant-tables" option but as soon as I run mysqld without that option, it dies again. I did try running "mysql_install_db --user=my

Re: Cannot start mysqld

2005-08-11 Thread Gobi
I find that I can start mysqld by using the "--skip-grant-tables" option but as soon as I run mysqld without that option, it dies again. I did try running "mysql_install_db --user=mysql" but when I did "mysqlshow mysql", it was empty. Any ideas on how to proceed? Thanks, Michael. Gleb Paha

Re: Cannot start mysqld

2005-08-10 Thread Gobi
Thanks for your reply. I confirmed that user and group, mysql, exists and performed the chown as instructed but same thing. Here is my log again after I did this: 050810 23:18:09 mysqld started 050810 23:18:09 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. Inn

Cannot start mysqld

2005-08-10 Thread Gobi
I installed mysql from the following rpm packages: mysql-4.1.10a-2.RHEL4.1 mysql-server-4.1.10a-2.RHEL4.1 I tried running 'mysqld start' and the server said startup failed. Here is the mysq.log: 050810 20:26:48 mysqld started InnoDB: The first specified data file ./ibdata1 did not exist: Inno