errors in mysql syntax

2007-09-27 Thread RAMYA

ALTER TABLE TimeTracker.TT_ProjectMembers ADD 
CONSTRAINT FK_Roles_Projects FOREIGN KEY 
( 
ProjectID 
) REFERENCES TimeTracker.TT_Projects ( 
ProjectID 
) ON DELETE CASCADE , 
CONSTRAINT FK_WorksOn_Users FOREIGN KEY 
( 
UserID 
) REFERENCES TimeTracker.TT_Users ( 
UserID 
) 



As iam new to this mysql when i was doing the program mysql shows the error
as 

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 'CONSTRAINT
FK_WorksOn_Users FOREIGN KEY 
( 
UserID 
) REFERENCES TimeTracke' at line 8 


what to do if this error comes plz anyone help me 



-- 
View this message in context: 
http://www.nabble.com/errors-in-mysql-syntax-tf4532650.html#a12935188
Sent from the MySQL - General mailing list archive at Nabble.com.


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



Re: mysql syntax

2005-04-19 Thread gerald_clark
Rich Brant wrote:
I forgot the important part: what I want is to filter on a userID in the
person table such as - 

SELECT u.Username, p.UserID
FROM Users u LEFT OUTER JOIN
 Person p ON u.UserID = p.UserID
WHERE (p.UserID = 5) OR
 (p.UserID IS NULL)
THis will return both the matching recs from the user table and NULLs from
the person table in sql server, but is what I cant get to work in mysql...
 

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


RE: mysql syntax

2005-04-19 Thread SGreen
OK, I don't see much wrong with this version either. 

Again I ask you:
Which version you are using?
Can you post some sample data and the incorrect results?

Here is a similar query that is working for me. This matches Projects with 
the people who have the resources to complete them (Suppliers). (If this 
data looks familiar to some readers, I also used these tables in an 
earlier thread):

CREATE TABLE people (
  name varchar(11) default NULL,
  rsrc varchar(15) default NULL
);

INSERT INTO people VALUES 
('noah','wood'),('noah','canvas'),('lincoln','wood'),('davinci','canvas'),('davinci','paint');

CREATE TABLE project (
  proj varchar(11) default NULL,
  rsrc varchar(15) default NULL
);

INSERT INTO project VALUES 
('ark','wood'),('ark','canvas'),('cabin','wood'),('monalisa','canvas'),('monalisa','paint'),('jeans','canvas'),('jeans','sewingmachine');

select * from people;

+-++
| name| rsrc   |
+-++
| noah| wood   |
| noah| canvas |
| lincoln | wood   |
| davinci | canvas |
| davinci | paint  |
+-++
5 rows in set (0.06 sec)

select * from project;

+--+---+
| proj | rsrc  |
+--+---+
| ark  | wood  |
| ark  | canvas|
| cabin| wood  |
| monalisa | canvas|
| monalisa | paint |
| jeans| canvas|
| jeans| sewingmachine |
+--+---+
7 rows in set (0.05 sec)

SELECT pr.proj, pr.rsrc,  p.name 
FROM project pr
LEFT JOIN people p
ON p.rsrc = pr.rsrc;

+--+---+-+
| proj | rsrc  | name|
+--+---+-+
| ark  | wood  | noah|
| ark  | wood  | lincoln |
| ark  | canvas| noah|
| ark  | canvas| davinci |
| cabin| wood  | noah|
| cabin| wood  | lincoln |
| monalisa | canvas| noah|
| monalisa | canvas| davinci |
| monalisa | paint | davinci |
| jeans| canvas| noah|
| jeans| canvas| davinci |
| jeans| sewingmachine | NULL|
+--+---+-+
12 rows in set (0.00 sec)

I get a NULL for person on the last line because nobody has a sewing 
machine to share for the "jeans" project.  To match your second query, I 
need to detect either a particular person ( I pick 'davinci') or a NULL.


SELECT pr.proj, pr.rsrc,  p.name 
FROM project pr
LEFT JOIN people p
ON p.rsrc = pr.rsrc
WHERE p.name='davinci'
or p.name is null;

+--+---+-+
| proj | rsrc  | name|
+--+---+-+
| ark  | canvas| davinci |
| monalisa | canvas| davinci |
| monalisa | paint | davinci |
| jeans| canvas| davinci |
| jeans| sewingmachine | NULL|
+--+---+-+
5 rows in set (0.00 sec)

Which is what we expect. Now, can you please show us what is wrong with 
your output?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



"Rich Brant" <[EMAIL PROTECTED]> wrote on 04/19/2005 03:46:33 PM:

> I forgot the important part: what I want is to filter on a userID in the
> person table such as - 
> 
> SELECT u.Username, p.UserID
> FROM Users u LEFT OUTER JOIN
>   Person p ON u.UserID = p.UserID
> WHERE (p.UserID = 5) OR
>   (p.UserID IS NULL)
> 
> THis will return both the matching recs from the user table and NULLs 
from
> the person table in sql server, but is what I cant get to work in 
mysql...
> 
> 
> 
> 
> 
> 
> 
>   _ 
> 
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, April 19, 2005 3:14 PM
> To: Rich Brant
> Cc: mysql@lists.mysql.com
> Subject: Re: mysql syntax
> 
> 
> 
> 
> Rich Brant <[EMAIL PROTECTED]> wrote on 04/19/2005 03:05:51 PM:
> 
> > I'm used to doing something simple such as the following in sql 
server:
> > 
> > SELECT u.Username, p.UserID
> > FROM   Users u LEFT JOIN
> >Person p ON u.UserID = p.UserID
> > 
> > However, I'm not seeing the same results in MySQL.  I don't get all
> > the recs in the users table and NULLs in the userID column from the
> > person table when the users.userID is not in the person table.  I get
> > no recs at all.  What am I missing here?
> > 
> > Thanks!
> > 
> I don't see any obvious problems with your query. I use LEFT JOINs all 
the
> time. 
> 
> Which version MySQL are you using? Can you give us an example of what 
your
> base data looks like (Users table and Person table), and what you 
actually
> got as a response? 
> 
> Shawn Green
> Database Administrator
> Unimin Corporation - Spruce Pine
> 


RE: mysql syntax

2005-04-19 Thread Rich Brant
I forgot the important part: what I want is to filter on a userID in the
person table such as - 
 
SELECT u.Username, p.UserID
FROM Users u LEFT OUTER JOIN
  Person p ON u.UserID = p.UserID
WHERE (p.UserID = 5) OR
  (p.UserID IS NULL)
 
THis will return both the matching recs from the user table and NULLs from
the person table in sql server, but is what I cant get to work in mysql...
 
 
 
 
 


  _  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 19, 2005 3:14 PM
To: Rich Brant
Cc: mysql@lists.mysql.com
Subject: Re: mysql syntax




Rich Brant <[EMAIL PROTECTED]> wrote on 04/19/2005 03:05:51 PM:

> I'm used to doing something simple such as the following in sql server:
> 
> SELECT u.Username, p.UserID
> FROM   Users u LEFT JOIN
>Person p ON u.UserID = p.UserID
> 
> However, I'm not seeing the same results in MySQL.  I don't get all
> the recs in the users table and NULLs in the userID column from the
> person table when the users.userID is not in the person table.  I get
> no recs at all.  What am I missing here?
> 
> Thanks!
> 
I don't see any obvious problems with your query. I use LEFT JOINs all the
time. 

Which version MySQL are you using? Can you give us an example of what your
base data looks like (Users table and Person table), and what you actually
got as a response? 

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



Re: mysql syntax

2005-04-19 Thread SGreen
Rich Brant <[EMAIL PROTECTED]> wrote on 04/19/2005 03:05:51 PM:

> I'm used to doing something simple such as the following in sql server:
> 
> SELECT u.Username, p.UserID
> FROM   Users u LEFT JOIN
>Person p ON u.UserID = p.UserID
> 
> However, I'm not seeing the same results in MySQL.  I don't get all
> the recs in the users table and NULLs in the userID column from the
> person table when the users.userID is not in the person table.  I get
> no recs at all.  What am I missing here?
> 
> Thanks!
> 
I don't see any obvious problems with your query. I use LEFT JOINs all the 
time.

Which version MySQL are you using? Can you give us an example of what your 
base data looks like (Users table and Person table), and what you actually 
got as a response?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

mysql syntax

2005-04-19 Thread Rich Brant
I'm used to doing something simple such as the following in sql server:

SELECT u.Username, p.UserID
FROM   Users u LEFT JOIN
   Person p ON u.UserID = p.UserID

However, I'm not seeing the same results in MySQL.  I don't get all
the recs in the users table and NULLs in the userID column from the
person table when the users.userID is not in the person table.  I get
no recs at all.  What am I missing here?

Thanks!

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



Re: Newbie: mysql syntax error question

2005-03-20 Thread Michael Stassen
Graham Anderson wrote:
My server has mysql:  version 3.23.58
// Performing SQL query
SELECT cities.city, regions.region, countries.country
 FROM cities
 JOIN subnets on subnets.cityid=subnets.cityid
  ^^^
Shouldn't that be
  JOIN subnets on subnets.cityid=cities.cityid?
 JOIN regions on subnets.regionid=regions.regionid
 JOIN countries on subnets.countryid=countries.countryid
 where subnets.subnetaddress='24.24.172'
this gives a syntax error:
#1064 - You have an error in your SQL syntax near 'on 
subnets.cityid=subnets.cityid
 JOIN regions on subnets.regionid=regions.regi' at line

all the tables seem proper named and populated.
what could this be ?
g
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Newbie: mysql syntax error question

2005-03-19 Thread Graham Anderson
My server has mysql:  version 3.23.58
// Performing SQL query
SELECT cities.city, regions.region, countries.country
 FROM cities
 JOIN subnets on subnets.cityid=subnets.cityid
 JOIN regions on subnets.regionid=regions.regionid
 JOIN countries on subnets.countryid=countries.countryid
 where subnets.subnetaddress='24.24.172'
this gives a syntax error:
#1064 - You have an error in your SQL syntax near 'on 
subnets.cityid=subnets.cityid
 JOIN regions on subnets.regionid=regions.regi' at line

all the tables seem proper named and populated.
what could this be ?
g
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: How to diagnose MySQL syntax error

2004-03-29 Thread beacker
Ken Elder writes:
>Today I experimented on two computers.  One consistently got the error
>message; the other consistently did not get the error message.  Both
>computers were Win98SE with IE6.0.  Their Win 98 and IE settings were
>identical (except for trivial stuff like home page and mouse controllers).
>They are on the same network.

 I would take a look at the logs for the web-server and see
if there are differences between the two accesses that show up in the
error or access logs.

 You may also want to check their DNS settings.  If you are accessing
two different machines due to different name -> ip mappings you could see
completely different responses.  The return from the DNS reverse lookup
could also cause some errors within the accesses.
   Brad Eacker ([EMAIL PROTECTED])



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



How to diagnose MySQL syntax error

2004-03-29 Thread Ken Elder
SQL gurus:

A few days ago we went live with a PHP/MySQL site.  One of the pages
requires entry of a username and password.  If a corresponding record is
found in the password table, the next page appears.

The authentication technique we used was a session variable.  For most
users, but not all, the server returned "You have an error in your SQL
syntax near '' at line 1".  So we passed the variable in the URL, and most
users still get the same error message.

Today I experimented on two computers.  One consistently got the error
message; the other consistently did not get the error message.  Both
computers were Win98SE with IE6.0.  Their Win 98 and IE settings were
identical (except for trivial stuff like home page and mouse controllers).
They are on the same network.

My partner and I are completely baffled by this.  How can a Web page
generate an SQL error on one computer, but not on an identical computer on
the same network?

Do any of you have suggestions for diagnosing something like this?  Or maybe
you have the secret for fixing the problem?  Is this the proper list for
asking a question like this, or would other lists or forums be more
appropriate?

Thanks in advance for any advice!
Ken Elder
Oklahoma City

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

Re: MySQL syntax question

2003-09-04 Thread Diana Soares
Hi, 

Have a look at:
http://www.mysql.com/doc/en/String_functions.html

You can find there functions to use in SELECT and WHERE clauses, like
UPPER(), LOWER(), SUBSTRING(), etc. and

http://www.mysql.com/doc/en/String_comparison_functions.html

for string comparison functions (LIKE, REGEXP, MATCH AGAINST, ...).



On Thu, 2003-09-04 at 18:32, Darryl Hoar wrote:
> greetings,
> When I am doing a select or update statement, I was wondering if there were
> functions to compare strings.  IE
> 
> Select * from employee,emp2 where uppercase(employee.fname)
> matches(emp2.fname*)
> 
> that is to compare two fields from two tables and see if they match
> regardless of whether
> one is upper,lower,mixed case.  Also see if table1.field1 is a partial match
> to another.
> 
> So,
> JOHNATHAN would match Jon or Jonny.
> 
> thanks,
> Darryl
-- 
Diana Soares


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



MySQL syntax question

2003-09-04 Thread Darryl Hoar
greetings,
When I am doing a select or update statement, I was wondering if there were
functions to compare strings.  IE

Select * from employee,emp2 where uppercase(employee.fname)
matches(emp2.fname*)

that is to compare two fields from two tables and see if they match
regardless of whether
one is upper,lower,mixed case.  Also see if table1.field1 is a partial match
to another.

So,
JOHNATHAN would match Jon or Jonny.

thanks,
Darryl


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



Re: strange mysql syntax error

2003-02-20 Thread Diana Soares
Hi, 

md5 is a function name, maybe that's why you need to quote the field
name. Check the MySQL manual about that.


On Thu, 2003-02-20 at 10:51, [EMAIL PROTECTED] wrote:
> >Description:
>   syntax checker reject length restriction when index char column
> with ending by number.
> 
> >How-To-Repeat:
>   alter table xmlmd5 add index md5 (md5(10));
>   ERROR 1064: You have an error in your SQL syntax near 'md5(10))' at line 1
>   column definition of md5 is md5 varchar(32)
> >Fix:
>   when I use quoted version it is OK
>   alter table xmlmd5 add index md5 (`md5`(10));
> 
-- 
Diana Soares


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




strange mysql syntax error

2003-02-20 Thread kubicek
>Description:
syntax checker reject length restriction when index char column
with ending by number.

>How-To-Repeat:
alter table xmlmd5 add index md5 (md5(10));
ERROR 1064: You have an error in your SQL syntax near 'md5(10))' at line 1
column definition of md5 is md5 varchar(32)
>Fix:
when I use quoted version it is OK
alter table xmlmd5 add index md5 (`md5`(10));

>Submitter-Id:  
>Originator:Petr Kubicek
>Organization: 
>MySQL support: none
>Synopsis:  strange syntax error
>Severity:  non-critical
>Priority:  low
>Category:  mysql
>Class: sw-bug
>Release:   mysql-3.23.49 (Source distribution)

>Environment:
System: Linux nagano.aspi.cz 2.4.18-10 #1 Wed Aug 7 10:26:48 EDT 2002 i686 unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 2731 (Red Hat Linux 7.3 2.96-112)
Compilation info: CC='gcc'  CFLAGS='-O2 -march=i386 -mcpu=i686 -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'  CXX='gcc'  CXXFLAGS='-O2 -march=i386 
-mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-rtti 
-fno-exceptions'  LDFLAGS=''
LIBC: 
lrwxrwxrwx1 root root   13 srp  3  2002 /lib/libc.so.6 -> libc-2.2.5.so
-rwxr-xr-x1 root root  1260480 èec  9  2002 /lib/libc-2.2.5.so
-rw-r--r--1 root root  2312370 èec  9  2002 /usr/lib/libc.a
-rw-r--r--1 root root  178 èec  9  2002 /usr/lib/libc.so
Configure command: ./configure  i386-redhat-linux --prefix=/usr --exec-prefix=/usr 
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share 
--includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec 
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man 
--infodir=/usr/share/info --without-debug --without-readline --enable-shared 
--with-extra-charsets=complex --with-bench --localstatedir=/var/lib/mysql 
--with-unix-socket-path=/var/lib/mysql/mysql.sock --with-mysqld-user=mysql 
--with-extra-charsets=all --with-innodb --with-berkeley-db --enable-large-files=yes 
--enable-largefile=yes --with-thread-safe-client --enable-assembler


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: MySQL syntax different from Microsoft SQL syntax...Please HELP

2002-03-18 Thread Paul DuBois

At 18:15 -0500 3/18/02, John Burns wrote:
>I've looked throught the MySQL documentation and I can't seem to find the
>answer to this problem.  I have a query that will work on a Microsoft SQL
>server, but I've tried moving it to a MySQL server and it won't work.  I
>tried modifying it and I can't get it to work either.  The scenario and
>syntax that I'm trying to use is below.  If anyone can help, I'd be
>EXTREMELY GRATEFUL!

What error do you get, exactly?  Is it a syntax error?  Does the query
execute but return the wrong answer, etc.?

Also, if gametime is present in more than one table, you should qualify
it with a table name.

>
>   select a.* b.fieldname, c.teamname as teamname1, d.teamname as teamname2,
>e.teamname as umpire_teamname
>   from games AS a
>   join fields AS b on a.field = b.fieldid
>   join teams AS c on a.team1 = c.teamid
>   join teams AS d on a.team2 = d.teamid
>   join teams AS e on a.umpire_team = e.teamid
>   WHERE gametime > "2001-04-12" and gametime <
>date_add("2001-04-12",interval 7 day)
>
>The scenario is as follows.  All of the information I want to grab is in the
>table named "games".  Some of the fields in the "games" are using ID #s that
>reference a row in the teams or field tables.  I basically want to output
>the data from the "games" table replacing the columns where there is a
>number with the corresponding name from the other table.  The columns team1,
>team2 and umpire_team are all numbers and I'm trying to get them to show up
>as the teamname that is listed for that number in the teams table.  The
>field column in the games table is a number and should get the fieldname
>from the fields table that corresponds with that number.  The where
>statement will really grab based on the current date, but I just have test
>data in the tables right now to try to get the query working.  The final
>output should look something like this:
>
>gametime (straight from the games table), team1 (field from the games table,
>joined with the teams table to show the team name), team2 (field from the
>games table, joined with the teams table to show to team name), umpire_team
>(field from the games table, joined with the teams table to show the team
>name), field (field from the games table, joined with the fields table to
>show the field name)
>
>
>-
>Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: MySQL syntax different from Microsoft SQL syntax...Please HELP

2002-03-18 Thread Christopher Thompson

What error message do you get?  Have you tried fully spelling out your join 
condition's table names?  Have you tried specifying that you are doing a LEFT 
join?  Have you tried using USING instead of ON?

On Monday 18 March 2002 4:15 pm, John Burns wrote:
> I've looked throught the MySQL documentation and I can't seem to find the
> answer to this problem.  I have a query that will work on a Microsoft SQL
> server, but I've tried moving it to a MySQL server and it won't work.  I
> tried modifying it and I can't get it to work either.  The scenario and
> syntax that I'm trying to use is below.  If anyone can help, I'd be
> EXTREMELY GRATEFUL!
>
>   select a.* b.fieldname, c.teamname as teamname1, d.teamname as teamname2,
> e.teamname as umpire_teamname
>   from games AS a
>   join fields AS b on a.field = b.fieldid
>   join teams AS c on a.team1 = c.teamid
>   join teams AS d on a.team2 = d.teamid
>   join teams AS e on a.umpire_team = e.teamid
>   WHERE gametime > "2001-04-12" and gametime <
> date_add("2001-04-12",interval 7 day)
>
> The scenario is as follows.  All of the information I want to grab is in
> the table named "games".  Some of the fields in the "games" are using ID #s
> that reference a row in the teams or field tables.  I basically want to
> output the data from the "games" table replacing the columns where there is
> a number with the corresponding name from the other table.  The columns
> team1, team2 and umpire_team are all numbers and I'm trying to get them to
> show up as the teamname that is listed for that number in the teams table. 
> The field column in the games table is a number and should get the
> fieldname from the fields table that corresponds with that number.  The
> where statement will really grab based on the current date, but I just have
> test data in the tables right now to try to get the query working.  The
> final output should look something like this:
>
> gametime (straight from the games table), team1 (field from the games
> table, joined with the teams table to show the team name), team2 (field
> from the games table, joined with the teams table to show to team name),
> umpire_team (field from the games table, joined with the teams table to
> show the team name), field (field from the games table, joined with the
> fields table to show the field name)
>
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]> Trouble
> unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




MySQL syntax different from Microsoft SQL syntax...Please HELP

2002-03-18 Thread John Burns

I've looked throught the MySQL documentation and I can't seem to find the
answer to this problem.  I have a query that will work on a Microsoft SQL
server, but I've tried moving it to a MySQL server and it won't work.  I
tried modifying it and I can't get it to work either.  The scenario and
syntax that I'm trying to use is below.  If anyone can help, I'd be
EXTREMELY GRATEFUL!

  select a.* b.fieldname, c.teamname as teamname1, d.teamname as teamname2,
e.teamname as umpire_teamname
  from games AS a
  join fields AS b on a.field = b.fieldid
  join teams AS c on a.team1 = c.teamid
  join teams AS d on a.team2 = d.teamid
  join teams AS e on a.umpire_team = e.teamid
  WHERE gametime > "2001-04-12" and gametime <
date_add("2001-04-12",interval 7 day)

The scenario is as follows.  All of the information I want to grab is in the
table named "games".  Some of the fields in the "games" are using ID #s that
reference a row in the teams or field tables.  I basically want to output
the data from the "games" table replacing the columns where there is a
number with the corresponding name from the other table.  The columns team1,
team2 and umpire_team are all numbers and I'm trying to get them to show up
as the teamname that is listed for that number in the teams table.  The
field column in the games table is a number and should get the fieldname
from the fields table that corresponds with that number.  The where
statement will really grab based on the current date, but I just have test
data in the tables right now to try to get the query working.  The final
output should look something like this:

gametime (straight from the games table), team1 (field from the games table,
joined with the teams table to show the team name), team2 (field from the
games table, joined with the teams table to show to team name), umpire_team
(field from the games table, joined with the teams table to show the team
name), field (field from the games table, joined with the fields table to
show the field name)


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Q: problem with MySQL syntax in Apple WebObjects

2001-09-25 Thread Alex Yu

Hello,

I am using mm mysql JDBC driver to connect WO5 to MySQL, but I am having
a problem with INSERT.  It seems like WO is executing this command for
inserting a new field.
 
  INSERT INTO test(ID, abc, def, ghi) VALUES (129, '', 'test',
'test')

But MySQL does not understand it.  It needs a space between the table
and fields. This command will work 

  INSERT INTO test (ID, abc, def, ghi) VALUES (129, '', 'test',
'test') 

Is this MySQL or WO's problem?

Best,
Alex
 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Mysql syntax

2001-07-20 Thread Allen Grace

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 21, 2001 12:33 PM
Subject: Mysql syntax

> If I wanted to asssign John Doe to system1, how would I write the
statement in sql to pull the sysid from the > system table via the sysname,
and then to update the user table with the sysid and John Doe?

INSERT INTO users (sysid, username)
SELECT sysid, 'John Doe'
FROM system
WHERE sysname = 'system1';

You might want to add a primary key to the users table (will come in handy
when you start querying this table), and an index to system.sysname.


--
Allen Grace

Dark Blue Sea Pty Ltd
ph +61 7 3007 
fax +61 7 3007 0001

***The opinions expressed in this email are my own and are not
representative of DBS Pty Ltd.***


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Mysql syntax

2001-07-20 Thread temu-jin

I have been trying to figure out how to do this, and I am sure that I am just 
overlooking somthing small.

Suppose I create two tables as follows:

CREATE TABLE system (
sysid INT NOT NULL UNSIGNED AUTO_INCREMENT PRIMARY KEY,
sysname VARCHAR(12),
os VARCHAR(10),
cpumhz INT
);

CREATE TABLE user (
sysid INT REFERENCES system,
username VARCHAR(30)
);

Also suppose that I populated the system table with the following information:

+---+---+++
| sysid | sysname |   os   | cpumhz |
+---+---+---+-+
| 1   |  system1 | Linux |   1000   |
| 2   | system2  | Unix  |300|
+---+---+-++

If I wanted to asssign John Doe to system1, how would I write the statement in sql to 
pull the sysid from the system table via the sysname, and then to update the user 
table with the sysid and John Doe?

Thanks,

Phil