backslash and Update

2005-12-30 Thread Jerry Swanson
I have 290 records in the database with backslashes. I want to remove the
backslashes.  Why the query below doesn't remove backslashes?

update name set first_name = REPLACE(first_name,'','') where first_name
like '%%';


How to start mysql on linux?

2005-11-22 Thread Jerry Swanson
I have sudo access to Linux box. How to start mysql 4.0.14.

TH


Reset root password to mysql?

2005-11-22 Thread Jerry Swanson
How to reset mysql password to mysql?


mysql -u root
ERROR 1045 (0): Access denied for user: '[EMAIL PROTECTED]' (Using
password: NO)


Re: Reset root password to mysql?

2005-11-22 Thread Jerry Swanson
Hot to start mysql server at boot?

On 11/22/05, Logan, David (SST - Adelaide) [EMAIL PROTECTED] wrote:

 Exactly as it is documented in the manual at :

 http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

 Regards


 David Logan
 Database Administrator
 HP Managed Services
 148 Frome Street,
 Adelaide 5000
 Australia

 +61 8 8408 4273 - Work
 +61 417 268 665 - Mobile
 +61 8 8408 4259 - Fax


 -Original Message-
 From: Jerry Swanson [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, 23 November 2005 12:11 PM
 To: mysql@lists.mysql.com
 Subject: Reset root password to mysql?

 How to reset mysql password to mysql?


 mysql -u root
 ERROR 1045 (0): Access denied for user: '[EMAIL PROTECTED]' (Using
 password: NO)



Re: SSH tunnel for Mysql

2005-11-21 Thread Jerry Swanson
Both Linux computers.


 On 11/21/05, Gleb Paharenko [EMAIL PROTECTED] wrote:

 Hello.



 You have not specified what operating system you're using. MySQL manual

 has some notes for Windows:

 http://dev.mysql.com/doc/refman/5.0/en/windows-and-ssh.html



 Jerry Swanson wrote:



 How to create ssh tunnel for Mysql?

 TH



 --
 For technical support contracts, goto https://order.mysql.com/?ref=ensita
 This email is sponsored by Ensita.NET http://www.ensita.net/
 __ ___ ___  __
 / |/ /_ __/ __/ __ \/ / Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
 /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET
 ___/ www.mysql.com http://www.mysql.com




 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]




SSH tunnel for Mysql

2005-11-20 Thread Jerry Swanson
How to create ssh tunnel for Mysql?
TH


How to write this query?

2005-11-10 Thread Jerry Swanson
How to write the query?
table1: order (order can have more than 1 item)
table2: item (has order_id).
table3: item_status (has item_status_id and item_id)
table4: status (has item_status_id). Status can be 'complete', 'pending'.

I need to get all orders that have ONLY completed items.
Examples:
if order has one item and it is completed, I need this order.
If order has 2 items and both completed, I need this order.
If order has 2 items, 1 is completed and 1 is not completed, I don't need
this order.

Thanks


Re: How to write this query?

2005-11-10 Thread Jerry Swanson
item_status table can have more than one status. I need to get the latest
status from the table.
 Thanks


 On 11/10/05, ISC Edwin Cruz [EMAIL PROTECTED] wrote:

 Try it:

 select distinct a.*
 from order a,
 item b,
 item_status c,
 status d
 where a.order_id = b.order_id
 and b.item_id=c.item_id
 and c.item_status_id = d.item_status_id
 where d.status = 'completed'

 It isnĀ“t tunned but I think that it works for that you want


 -Mensaje original-
 De: Jerry Swanson [mailto:[EMAIL PROTECTED]
 Enviado el: Jueves, 10 de Noviembre de 2005 06:23 a.m.
 Para: mysql@lists.mysql.com
 Asunto: How to write this query?


 How to write the query?
 table1: order (order can have more than 1 item)
 table2: item (has order_id).
 table3: item_status (has item_status_id and item_id)
 table4: status (has item_status_id). Status can be 'complete', 'pending'.

 I need to get all orders that have ONLY completed items.
 Examples:
 if order has one item and it is completed, I need this order. If order has
 2
 items and both completed, I need this order. If order has 2 items, 1 is
 completed and 1 is not completed, I don't need this order.

 Thanks





Re: Delete all but the newest 100 records?

2005-11-06 Thread Jerry Swanson
If you have auto_incremnt id in the table you can do the following:
delete from table a where id  start_id and id = end_id

Or you can delete by timestamp.
delete from table a where date between 'start_date' and 'end_date'.



On 11/6/05, Brian Dunning [EMAIL PROTECTED] wrote:

 I'd like to delete all but the newest 100 records from a table. I
 have a timestamp field. I can't figure out how to do this in a single
 SQL statement - can anyone help? Thanks!

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]




Differnce between fields of int type

2005-11-02 Thread Jerry Swanson
What is the difference between these two fields?
Both fields hold number 5, but for some query marked_id field gives result.

marked_id | int(11) | | | 0 |
id | int(11) | YES | | NULL |


Where you can see difference between these fields?

TH


float comparison?

2005-10-29 Thread Jerry Swanson
Why when I do select from database and try to compare float field with float
number, I have no results

amount --- type float

select * from price where amount = 3.45 // doesn't work
select * from price where amount = '3.45' //doesn't work

select * from price where amoun like '3.45' //work

My question is how to compare float field with float number. What operator I
should use?


float size?

2005-10-01 Thread Jerry Swanson
I have field in database type float. When I insert number like 12345.27 ,
number is inserted 12345.3

Why it happened?


Group by Month

2005-07-20 Thread Jerry Swanson
I have query that pulls data between to dates. How to group the data by month?

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



LIke

2005-06-28 Thread Jerry Swanson
How to make this work? 

field like '%DATA_FORMAT(now(), '%m%d%y') %'

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Install Mysql 4 on Fedora Core 2

2005-06-13 Thread Jerry Swanson
I want to install MySQL 4 on Fedora Core 2.
Questions:
#1. Do I need to uninstall MySQL 3 from the server first?

#2. Where I can get source for MySQL 4?

Thanks

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



mysql: varchar and case sensitive

2005-06-02 Thread Jerry Swanson
Column type is username varchar(100).

When I do select from database:
select * from user where username='John';  //returns one row
select * from user where username='john'; //returns one row

The records in the database has username 'John'.

Why it  isn't case sensitive? 'John and 'john' .. are two different strings..?

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



View

2005-06-02 Thread Jerry Swanson
Does Mysql 4 supports views?

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: varchar(10) to decimal

2005-05-18 Thread Jerry Swanson
decimal(6,2)

On 5/18/05, Philippe Poelvoorde [EMAIL PROTECTED] wrote:
 Jerry Swanson wrote:
 
  I need to change format from varchar(10) to decimal.
  When I alter the table the data is trimmed.
 
  What I'm doing wrrong?
 
  TH
 
 
 ALTER TABLE your_table MODIFY your_column double NOT NULL DEFAULT '0.0';
 should normally work. What is the command you are doing and have you
 example results ?
 How did you declare your decimal column ?
 
 --
 Philippe Poelvoorde
 COS Trading Ltd.
 
 --
 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]



varchar(10) to decimal

2005-05-17 Thread Jerry Swanson
I need to change format from varchar(10) to decimal. 
When I alter the table the data is trimmed.

What I'm doing wrrong?

TH

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



write query question

2005-05-11 Thread Jerry Swanson
How to select 5 records(including username, first_name, last_name,
contact) for each user in the database?

table user(
id,
username,
first_name,
last_name
)

contact(
id
id_user //id from user table 
name
)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: write query question

2005-05-11 Thread Jerry Swanson
I need 5 records per user.

On 5/11/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,
 try this,
 
 select username, first_name,last_name, name as contact
 from user,contact
 where user.id=contact.user_id
 order by username;
 
 Mathias
 
 Selon Jerry Swanson [EMAIL PROTECTED]:
 
  How to select 5 records(including username, first_name, last_name,
  contact) for each user in the database?
 
  table user(
id,
username,
first_name,
last_name
  )
 
  contact(
id
id_user //id from user table
name
  )
 
  --
  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]



Re: write query question

2005-05-11 Thread Jerry Swanson
query runs  for 5 min... kill query id.



On 12 May 2005 00:29:56 +0200, Harald Fuchs [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
 Eric Jensen [EMAIL PROTECTED] writes:
 
  So you want 5 contacts for every user?  Try this:
  SELECT COUNT(c.id) AS count, u.username,  u.first_name,  u.last_name,
  c.name
  FROM user AS u, contact AS c
  WHERE u.id = c.id_user
  GROUP BY c.id_user
  HAVING count = 5
 
 This won't work since count would be the total number of contacts
 for this user.
 
 Try something like that:
 
   SELECT u.username, c1.name
   FROM user AS u
   JOIN contact AS c1 ON u.id = c1.id_user
   LEFT JOIN contact AS c2 ON c2.id_user = c1.id_user
  AND c2.name  c1.name
   GROUP BY u.username, c1.name
   HAVING count(c2.id)  5
   ORDER BY u.username, c1.name
 
 
 --
 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]



REPLACE function

2005-04-28 Thread Jerry Swanson
I have field varchar(20) that stores phone numbers. Phone number can
be in different format. So I need only digits from the field. How I
can do such replacement?

TH

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



update random date

2005-04-03 Thread Jerry Swanson
How to update randomly field date of datetime?  I need to update
randomly on 300 records
Thanks

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Query question

2005-03-29 Thread Jerry Swanson
I want to get everything from user than if record exist in admin so
user has admin(administrator) in table user with user.id =
admin.admin_id, so I need to get 'admin' first_name and last_name

If there is no record in table admin with adin.user_id = user.id ,
than I need at least all records from user

Table: user
| id| int(10) |  | PRI | NULL 
  | auto_increment |
| email | varchar(100)| YES  | | NULL 
  ||
| password  | varchar(45) | YES  | | NULL 
  ||
| first_name| varchar(100)| YES  | | NULL 
  ||
| last_name | varchar(100)| YES  | | NULL 
  ||
| type  | enum('admin','user')| YES  | | NULL 
  | auto_increment |

Table: admin
| id| int(10)  |  | PRI | NULL| auto_increment |
| admin_id  | int(10)  | YES  | | NULL||
| user_id   | int(10)  | YES  | | NULL||
| date  | datetime | YES  | | NULL||

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Fedora Core 2: upgrade mysql 3 to mysql 4

2005-02-27 Thread Jerry Swanson
I want to upgrade mysql 3 to mysql 4.
Operating System is Fedore Core 2. Is there any package dependency?

How to remove mysql3 and install mysql 4?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: how to write this query?

2005-02-21 Thread Jerry Swanson
It's not precisely correct. 

When time difference is less than 7, the time is calcualted wrong 

end_time 2005-01-10 17:53:33 
end_time  2005-01-04 16:44:57

Result: days 6
Result: bussiness_days 6




On Sat, 19 Feb 2005 09:50:06 -0500, Mike Rains [EMAIL PROTECTED] wrote:
 On Sat, 19 Feb 2005 14:01:05 +, Jerry Swanson [EMAIL PROTECTED] wrote:
  I have two dates (start_date, end_date). Datediff() function returns
  difference in days.
  I need the difference but not including Satuday and Sunday.
 
  Any ideas?
 
 C:\Program Files\MySQL\MySQL Server 4.1\binmysql -utest -ptest test
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 43 to server version: 4.1.8-nt
 
 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
 mysql CREATE TABLE `DateDiffs` (
 -  start_date DATETIME,
 -  end_date DATETIME
 - );
 Query OK, 0 rows affected (0.15 sec)
 
 mysql INSERT INTO DateDiffs
 - (start_date, end_date)
 -   VALUES
 - ('2005-02-14 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-02-07 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-02-04 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-31 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-28 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-28 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-24 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-21 00:00:00', '2005-02-18 00:00:00'),
 - ('2005-01-17 00:00:00', '2005-02-18 00:00:00');
 Query OK, 9 rows affected (0.06 sec)
 Records: 9  Duplicates: 0  Warnings: 0
 
 mysql SELECT
 -start_date,
 -end_date,
 -datediff(end_date, start_date)
 -AS dd1,
 -datediff(end_date, start_date) -
 floor(datediff(end_date, start_date) / 7) * 2
 -AS dd2
 - FROM DateDiffs
 - ORDER BY start_date;
 +-+-+--+--+
 | start_date  | end_date| dd1  | dd2  |
 +-+-+--+--+
 | 2005-01-17 00:00:00 | 2005-02-18 00:00:00 |   32 |   24 |
 | 2005-01-21 00:00:00 | 2005-02-18 00:00:00 |   28 |   20 |
 | 2005-01-24 00:00:00 | 2005-02-18 00:00:00 |   25 |   19 |
 | 2005-01-28 00:00:00 | 2005-02-18 00:00:00 |   21 |   15 |
 | 2005-01-28 00:00:00 | 2005-02-18 00:00:00 |   21 |   15 |
 | 2005-01-31 00:00:00 | 2005-02-18 00:00:00 |   18 |   14 |
 | 2005-02-04 00:00:00 | 2005-02-18 00:00:00 |   14 |   10 |
 | 2005-02-07 00:00:00 | 2005-02-18 00:00:00 |   11 |9 |
 | 2005-02-14 00:00:00 | 2005-02-18 00:00:00 |4 |4 |
 +-+-+--+--+
 9 rows in set (0.00 sec)
 
 mysql DROP TABLE DateDiffs;
 Query OK, 0 rows affected (0.19 sec)
 
 mysql exit
 
 The column dd1 contains the unaltered DATEDIFF() which includes the
 Saturdays and Sundays, while the dd2 column contains the number of
 business days omitting the weekend days.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



how to write this query?

2005-02-19 Thread Jerry Swanson
I have two dates (start_date, end_date). Datediff() function returns
difference in days.
I need the difference but not including Satuday and Sunday.

Any ideas?

TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



UNIX_TIMESTAMP function

2005-02-17 Thread Jerry Swanson
How to select datetime using UNIX_TIMESTAMP excluding Saturday and Sunday?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Daily Incremental Backups on Mysql

2005-02-10 Thread Jerry Swanson
Does binary logs are avaialbe in Mysql 4 or only in Mysql 5?
Thanks 



On Thu, 10 Feb 2005 10:28:56 +1100, Daniel Kasak
[EMAIL PROTECTED] wrote:
 Jerry Swanson wrote:
 
 Is it possible to do daily incremental backups on mysql?
 
 
 Thanks
 
 
 
 Yes.
 mysqldump will give you a starting point, and the binary transaction
 logs give you your incremental backups - copy these somewhere each day -
 onto a backup tape or something. Read the documentation for mysqldump
 and for processing the binary transaction logs.
 
 --
 Daniel Kasak
 IT Developer
 NUS Consulting Group
 Level 5, 77 Pacific Highway
 North Sydney, NSW, Australia 2060
 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
 email: [EMAIL PROTECTED]
 website: http://www.nusconsulting.com.au
 
 --
 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]



Daily Incremental Backups on Mysql

2005-02-09 Thread Jerry Swanson
Is it possible to do daily incremental backups on mysql? 


Thanks

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Elegant way: select last record from table

2005-01-21 Thread Jerry Swanson
I'm interesting to know what is the best way to select  last inserted record.

This can do it  ORDER BY id desc limit 5 .. but ..

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



mysql store queries?

2005-01-21 Thread Jerry Swanson
Does mysql stores queries?  If so where?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: select count

2005-01-13 Thread Jerry Swanson
This is what I was looking for. Why  the query is call cross-tab?
TH


On Thu, 13 Jan 2005 02:09:45 +, Ian Sales [EMAIL PROTECTED] wrote:
 Jerry Swanson wrote:
 
 | Field| Type
| Null | Key | Default | Extra  |
 +--+--+--+-+-++
 | id   | int(10)
|  | PRI | NULL| auto_increment |
 | status   | enum('received','send','cancelled')
| YES  | | NULL||
 | notes| longblob
| YES  | | NULL||
 | date | datetime
| YES  | | NULL||
 +--+--+--+-+-++
 
 
 I have table account (see below). 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 status='cancelled';
 
 Is it possible to get count of each status in one query instead of 3?
 
 
 
 
 - you could use a cross-tab query:
 
 SELECT
 date,
 SUM(IF(CONCAT(status,id) LIKE 'received%',1,0)) as received,
 SUM(IF(CONCAT(status,id) LIKE 'send%',1,0)) as send,
 SUM(IF(CONCAT(status,id) LIKE 'cancelled%',1,0)) as cancelled
 FROM
 account
 GROUP BY date;
 
 - ian
 
 --
 +---+
 | Ian Sales  Database Administrator |
 |   |
 | eBuyer  http://www.ebuyer.com |
 +---+
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: select count

2005-01-13 Thread Jerry Swanson
What query suppose to be faster? Jan or Dave?

Jan Solution:
SELECT
date,
SUM(IF(CONCAT(status,id) LIKE 'received%',1,0)) as received,
SUM(IF(CONCAT(status,id) LIKE 'send%',1,0)) as send,
SUM(IF(CONCAT(status,id) LIKE 'cancelled%',1,0)) as cancelled
FROM
account
GROUP BY date;


On Wed, 12 Jan 2005 22:51:00 -0500, Dave Merrill [EMAIL PROTECTED] wrote:
  I have table account (see below). 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 status='cancelled';
 
  Is it possible to get count of each status in one query instead of 3?
 
 How about this:
 
 select
   (select count(*) from account where status = 'received') as
 count_received,
   (select count(*) from account where status = 'send') as count_send,
   (select count(*) from account where status = 'cancelled') as
 count_cancelled
 
 You could also build a stored proc that looped over a list of the values to
 find, or, I think maybe, over the actual distinct values in the field. Not
 so sure about that part.
 
 Dave Merrill
 
 --
 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]



Re: select count

2005-01-13 Thread Jerry Swanson
What is the difference between '='' and ''?
TH


On Thu, 13 Jan 2005 09:13:07 -0500, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 I would think that the Jan solution should execute in a single pass through
 the table. The Dave (subquery) version will probably need to make 3 passes
 through the table get the same results. 
 
  As was mentioned in another response, the inequality comparisons
 (=,,,etc.) are much faster than a LIKE comparison. So, I would also
 suggest simplifying Jan's solution to read   IF(status='xxx',1,0) instead
 of IF(concat() LIKE ...,1,0) . 
 
 Shawn Green
 Database Administrator
 Unimin Corporation - Spruce Pine 
 
 Jerry Swanson [EMAIL PROTECTED] wrote on 01/13/2005 07:56:18 AM:
 
 
  What query suppose to be faster? Jan or Dave?
  
  Jan Solution:
  SELECT
  date,
  SUM(IF(CONCAT(status,id) LIKE 'received%',1,0)) as received,
  SUM(IF(CONCAT(status,id) LIKE 'send%',1,0)) as send,
  SUM(IF(CONCAT(status,id) LIKE 'cancelled%',1,0)) as cancelled
  FROM
  account
  GROUP BY date;
  
  
  On Wed, 12 Jan 2005 22:51:00 -0500, Dave Merrill [EMAIL PROTECTED] wrote:
I have table account (see below). 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 status='cancelled';
   
Is it possible to get count of each status in one query instead of 3?
   
   How about this:
   
   select
 (select count(*) from account where status = 'received') as
   count_received,
 (select count(*) from account where status = 'send') as count_send,
 (select count(*) from account where status = 'cancelled') as
   count_cancelled
   
   You could also build a stored proc that looped over a list of the values
 to
   find, or, I think maybe, over the actual distinct values in the field.
 Not
   so sure about that part.
   
   Dave Merrill
   
   --
   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]
  


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



subquery, returns more than one filed?

2005-01-13 Thread Jerry Swanson
Can subquery return more than one column in Mysql 4.1.7?

SELECT (select user.last_name, user.first_name from actor where
user.id=6) as last_name, first_name
  (select count(*) from account where account.status = 'progress') as
progress_count,


ERROR 1241 (21000): Operand should contain 1 column(s)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



select count

2005-01-12 Thread Jerry Swanson
| Field| Type 
   | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(10)  
   |  | PRI | NULL| auto_increment |
| status   | enum('received','send','cancelled')  
   | YES  | | NULL||
| notes| longblob 
   | YES  | | NULL||
| date | datetime 
   | YES  | | NULL||
+--+--+--+-+-++


I have table account (see below). 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 status='cancelled';

Is it possible to get count of each status in one query instead of 3?

TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Mysql upgrade problem 3.23 to 4.1

2004-12-21 Thread Jerry Swanson
I upgraded mysql  mysql-3.23.58-1  to  mysql4.1

In mysql-3.23 ( I have this field)
password  | varbinary(45)   | YES  | | NULL   
|

I inserted data into this field as password('pass').

I have php script that checks if login valid.  mysql-3.23 and
mysql-4.1 have identical data.

It worked on mysql-3.23 but doesn't work on mysql4.1. Password don't match.

Any ideas why?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



String function

2004-11-23 Thread Jerry Swanson
I need to make query that adds numbers. The fields are varchar format
so I have some value 12121 and some values 121212,121212.

I think I need string replace function that replace comma. What
function can do this?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



How many rows?

2004-11-13 Thread Jerry Swanson
This is my query
select id, status from sale  where user_id = 1 GROUP BY id;
 
I need to know how many rows or how many entries this query returns. I
tried to use count and sum. But the result is wrong.

I want to be able to make select and know how many rows this query
returns. Now, I use mysql_num_rows in php,

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



MySQL logs and restore data

2004-11-08 Thread Jerry Swanson
I deleted some data in mysql. Is it possible to restore the data.
Maybe using MYSQL logs?

Thanks

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



MySQL logs and restore data

2004-11-08 Thread Jerry Swanson
I deleted some data in mysql. Is it possible to restore the data.
Maybe using MYSQL logs?

Thanks

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



ORDER by date: reverse order

2004-11-05 Thread Jerry Swanson
I want to sort by date but the last date appears first. How to write such query?

TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Redirect output to the file

2004-11-04 Thread Jerry Swanson
I want to redirect output of the query to the file in tab delimited
format. Can this be done?
Thanks

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



MySQL Control Center and Linux box connection

2004-10-31 Thread Jerry Swanson
I have Linux box running Red Hat and 3.23. I  install MySQL Contorl
Center and trying connect to the mysql on Linux box.

When I try to connect I receive the error message.
ERROR: HOST 'ip address' is not allowed to connect to this MySQL server.

What I'm doing wrong here?

TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: mysql 3.23 store large data

2004-10-29 Thread Jerry Swanson
How many characters can Longblob hold? 
What is the size of longblob?
Why I don't need to specify the size (i.e varchar(200) )?



On Wed, 27 Oct 2004 20:09:37 +0300, Gleb Paharenko
[EMAIL PROTECTED] wrote:
 Hi.
 
 Use LONGBLOB.
 
 
 
 
 Jerry Swanson [EMAIL PROTECTED] wrote:
 
  What type I should use in MySQL 3.23.58 to store large data file?
 
 
 
 
 --
 For technical support contracts, goto https://order.mysql.com/?ref=ensita
 This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
 /_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
   ___/   www.mysql.com
 
 --
 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]



mysql 3.23 store large data

2004-10-27 Thread Jerry Swanson
What type I should use in MySQL 3.23.58 to store large data file?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



date type select

2004-10-26 Thread Jerry Swanson
I have comlumn in mysql type datetime. I need to get the date in DATE format.
select DATE(reg_date) as test from a1; 

It gives me an error.
How to select  date in different date format?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Delete data from more than one table

2004-10-14 Thread Jerry Swanson
I can delete data for one table with no problem:
delete from table;

I need to delete data for more than one table.
I tried to run this query: 

delete from account, survey;
//But the query crashes.
 
Any ideas how to delete data for more than one query.
TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Modify type

2004-10-14 Thread Jerry Swanson
I have field date type of datetime. I need to modify to timestamp.
If I alter the table and mofiy the field will this crash the data in
the field.

TH

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]