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:
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.