Jump to content

not unique table/alias


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 post
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 post
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 post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...