Jump to content

not unique table/alias


nasution

Recommended Posts

I get the error ERROR 1066 (42000): Not unique table/alias:I cant figure out whats wrong with it.SELECT p.id as id_produk, p.nama_produk, p.stok, p.url_title, p.deskripsi, p.file_name, p.id_kategori_produk, p.fk_jenis_id,p.fk_merk_id, p.fk_gudang_id, p.created_at, kp.id, kp.nama_kategori, jm.id, jm.jenis_material, mm.id, mm.merk_material, gm.id, gm.gudang_material FROM produk as p, kategori_produk as kp, produk as p, jenis_material as jm, produk as p, merk_material as mm, produk as p, gudang_material as gm WHERE p.id_kategori_produk = kp.id, p.fk_jenis_id = jm.id, p.fk_merk_id = mm.id, p.fk_gudang_id = gm.id ORDER BY created_at DESC LIMIT 0, 15Filename: C:xampphtdocstelkomaksessystemdatabaseDB_driver.phpLine Number: 330

Link to comment
Share on other sites

It seems you're using the alias "p" multiple times for the same table:

 

FROM produk as p, kategori_produk as kp, produk as p, jenis_material as jm, produk as p, merk_material as mm, produk as p, gudang_material as gm

 

You only need to put the table once.

Link to comment
Share on other sites

FROM produk as p, kategori_produk as kp, produk as p, jenis_material as jm, produk as p,

Did you see to much Ayou metion table as P, you need make alias table diffrent with each table her eis i give simple

Select * from product a, kategori b, merk c where a.id_kategori=b.id_kategori and a.id_merk=c.id_merk

Look above i make alias each table with diffrent table hope you understand query above, here is give trick

 

 

  1. You need to alias each table with diffrent name, just use abjad make you understand fast !
  2. when you trying join please remember where is came from field then use alias

 

If you don't get it please provide us your name table and what you want so we can guide you,

 

 

 

Freddy Sidauruk

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...