Terry Spencer
Haigh Consultancy Services
Tel: +44 (0)116 262 3966
Fax: +44 (0)116 262 3946 (Leciester Office)
Fax: +44 (0)870 052 4572 (Terry)
Mob: +44 (0)7796108244
www.haigh-cs.co.uk http://www.haigh-cs.co.uk
Hi All,
I have a question for clearer brains than mine. I would like to join two
tables,. There may be many possible joins in table B to table A, but I only
want to join one row from B to table A - the row with the closest, but
lesser date.
TABLE A
Row Id date
1 46 3 Jan
7
I can connect on the command line, but have problems connecting using DBI/D
on the same server.
# ./bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.0-alpha-standard
Mysql is running
# ps -ef | grep mysql
root 10626
There are a few options, for more information see
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2)
Returns the integer difference between the date or datetime expressions
datetime_expr1 and datetime_expr2. The unit for the
Im trying to speed up a query.
select
project_id
from
timesheet ts
where
ts.del is null
and signoff = 'A'
The output of explain is detailed below.
++-+---+--+-+--+
| id | select_type | table | type | possible_keys | key
From the manual:
REPLACE(str,from_str,to_str)
Returns the string str with all occurrences of the string from_str replaced
by
the string to_str:
mysql SELECT REPLACE('www.mysql.com', 'w', 'Ww');
- 'WwWwWw.mysql.com'
This function is multi-byte safe.
Terry Spencer
Haigh Consultancy Services
+44
.
With the help of EXPLAIN, you can see when you must add indexes to tables to
get a faster SELECT that uses indexes to find the records.
http://www.mysql.com/doc/en/EXPLAIN.html
Terry Spencer
Haigh Consultancy Services
+44 (0)2073007329
www.haigh-cs.co.uk
-Original Message-
From: Paul
this error?
Thanks
Terry
Terry Spencer
Haigh Consultancy Services
+44 (0)2073007329
www.haigh-cs.co.uk
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Im attempting to update a table. We perform a select on the table to
determine what row to update.
update test a
set
visit_date = now()
where
a.id in (select b.id from test b where code ='Z')
Running this generates an error.
You cant specify target table 'test' for update in FROM clause.
I
appreciated.
Im using 4.1.
Thanks
Terry
-Original Message-
From: Mike Hillyer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 2:53 PM
To: Terry Spencer; [EMAIL PROTECTED]
Subject: RE: Update in select
Subqueries are only available in MySQL 4.1. However, you should be able
to write
10 matches
Mail list logo