Jump to content

MYSQL error message unable to enter data in table


jetpacmidge

Recommended Posts

Hi,

I am using PHP v5, MYSQL v5 and Apache v1.3.

When I try and enter a query into the MYSQL command client line I am unable to enter data into the table :-

SQL query :-

[code]INSERT INTO fixturesresults (season,age,division,hometeam,awayteam) VALUES (SELECT home.season,home.age,home.division,home.team,away.team FROM team as home, team as away WHERE home.team !=away.team);[/code]

TABLE NAME - team

+----------+----------+------+-----+---------+-------+
| Field    | Type    | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| season  | char(10) | NO  | PRI | NULL    |      |
| age      | char(15) | NO  | PRI | NULL    |      |
| division | char(20) | NO  | PRI | NULL    |      |
| team    | char(30) | NO  | PRI | NULL    |      |
+----------+----------+------+-----+---------+-------+

TABLE NAME - fixturesresults

+-----------+-----------------+------+-----+------------+-------+
| Field    | Type            | Null | Key | Default    | Extra |
+-----------+-----------------+------+-----+------------+-------+
| season    | char(10)        | NO  | PRI | NULL      |      |
| age      | char(15)        | NO  | PRI | NULL      |      |
| division  | char(20)        | NO  | PRI | NULL      |      |
| hometeam  | char(30)        | NO  | PRI | NULL      |      |
| awayteam  | char(30)        | NO  | PRI | NULL      |      |
| homescore | int(3) unsigned | NO  |    | 0          |      |
| awayscore | int(3) unsigned | NO  |    | 0          |      |
| date      | date            | NO  |    | 0000-00-00 |      |
+-----------+-----------------+------+-----+------------+-------+

ERROR MESSAGE :-

[code]ERROR 1064 (42000): 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 'SELEC
T home.season,home.age,home.division,home.team,away.team FROM team as home,' at
line 1[/code]

Thanks

  :shock:
I don't think there should be a VALUES when your using insert ... select

[code]
INSERT INTO fixturesresults (season,age,division,hometeam,awayteam) SELECT home.season, home.age, home.division, home.team, away.team FROM team as home, team as away WHERE home.team !=away.team;
[/code]


/Magnus

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.