• (2 Pages)
  • +
  • 1
  • 2

Beginners guide to Creating simple MySQL tables Intro to: creating db, tables, columns, keys...

#16 Jud202  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 53
  • Joined: 02-March 09

Posted 09 November 2010 - 11:05 AM

This is a great tutorial but I have one issue, see the output below:


mysql> select*from products;
+-----------+------------+-------------+-----------+
| ProductID | SupplierID | ProductName | UnitPrice |
+-----------+------------+-------------+-----------+
|     00001 |      00001 | Chocolates  |     10.50 |
+-----------+------------+-------------+-----------+
1 row in set (0.15 sec)

mysql> insert into products (supplierID, productname, unitprice) value ('2','Beads', '5');
Query OK, 1 row affected (0.00 sec)

mysql> select*from products;+-----------+------------+-------------+-----------+
| ProductID | SupplierID | ProductName | UnitPrice |
+-----------+------------+-------------+-----------+
|     00001 |      00001 | Chocolates  |     10.50 |
|     00002 |      00002 | Beads       |      5.00 |
+-----------+------------+-------------+-----------+
2 rows in set (0.03 sec)

mysql> insert into products (supplierID, productname, unitprice) value ('10','Beads', '5');
Query OK, 1 row affected (0.00 sec)

mysql> select*from products;+-----------+------------+-------------+-----------+
| ProductID | SupplierID | ProductName | UnitPrice |
+-----------+------------+-------------+-----------+
|     00001 |      00001 | Chocolates  |     10.50 |
|     00002 |      00002 | Beads       |      5.00 |
|     00003 |      00010 | Beads       |      5.00 |
+-----------+------------+-------------+-----------+
3 rows in set (0.00 sec)

mysql> select*from suppliers;
+------------+--------------+-------------+------------------+
| SupplierID | SupplierName | Phone       | Email            |
+------------+--------------+-------------+------------------+
|      00001 | ABCSupplier  | 14036801234 | abc@dicforum.com |
+------------+--------------+-------------+------------------+
1 row in set (0.00 sec)




and as you can see I did not get an error and I actually have 3 products existing with only 3 different supplier IDs but only 1 actual supplier.

Any reason why this might happen?

I also tried remaking a new database incase I had a typo and I got the same thing.
Was This Post Helpful? 0
  • +
  • -

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6037
  • View blog
  • Posts: 23,432
  • Joined: 23-August 08

Posted 13 November 2010 - 08:11 AM

Are you SURE you added the FOREIGN KEY, as shown here:

ALTER TABLE Products
ADD FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID);


?
Was This Post Helpful? 0
  • +
  • -

#18 canxoniam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-May 10

Posted 28 December 2010 - 02:17 AM

hey thanks
Was This Post Helpful? 0
  • +
  • -

#19 hmmcode  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-January 12

Posted 04 January 2012 - 04:38 AM

View Postrapheal2k8, on 27 April 2009 - 07:12 AM, said:

Hi!..After typing
INSERT INTO suppliers (SupplierName, Phone, Email) VALUE (‘ABCSupplier’,’1122334455’,’abc@dicforum.com’);

i got this '> and nothing i type seems to do anything. pls help me out.

Hi!..After typing
INSERT INTO suppliers (SupplierName, Phone, Email) VALUE (‘ABCSupplier’,’1122334455’,’abc@dicforum.com’);

i got this '> and nothing i type seems to do anything. pls help me out.


I have the same problem after typing in that line of code. Did anyone realsie why that happened? Many thanks!

I have the same problem as rapheal2k8 - I get new lines with'> instead of -> and the program doesnt return anything else. Does anyone know why this may have happened? Thanks in advance
Was This Post Helpful? 0
  • +
  • -

#20 James_Smith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 20-July 12

Posted 21 January 2013 - 02:04 AM

Nice and informative MySQL guide for beginners with all necessary detailed information to learn and understand. Great work, keep it up. Thumps up for your effort.
Was This Post Helpful? 0
  • +
  • -

#21 Golossos  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 117
  • Joined: 29-June 13

Posted 28 July 2013 - 12:36 AM

I too did not know where to start after installing WAMP, so I figured I would give MySQL a dabble since I have been acquainted with PHP. Great tutorial!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2