⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Column 'username' in where clause is ambiguous



likhon3k
  • profile picture
  • Member

Posted 24 January 2015 - 10:27 AM

I have found an error like ambiguous and tried to solve many but failed.

 

whenever, I add a relation joining then I found this error. but relation joining is okay on all other functions.

 

 

Error Number: 1052

Column 'username' in where clause is ambiguous

SELECT `files_upload`.*, j68a7d484.meta_title AS s68a7d484 FROM (`files_upload`) LEFT JOIN `meta_upload` as j68a7d484 ON `j68a7d484`.`id` = `files_upload`.`file_type` WHERE `username` = 'likhon3k' ORDER BY `create_date` DESC, `create_date` DESC LIMIT 16

Filename: .../models/grocery_crud_model.php

Line Number: 87

 

 

any help please?


Amit Shah
  • profile picture
  • Member

Posted 24 January 2015 - 16:48 PM

use <tablename>.username .. that should solve..!!


likhon3k
  • profile picture
  • Member

Posted 25 January 2015 - 14:15 PM

use <tablename>.username .. that should solve..!!

 

No. after doing as per your instruction, I am getting another error. when I want to click Add button to add more data then getting the following error:

 

Error Number: 1054

 

Unknown column 'scan_files.username' in 'where clause'

 

SELECT COUNT(*) AS `numrows` FROM (`meta_upload`) WHERE `scan_files`.`username` = 'istiaque' AND `username` = 'istiaque' ORDER BY `create_date` DESC


Amit Shah
  • profile picture
  • Member

Posted 26 January 2015 - 17:55 PM

well.. exactly u will gt error - look @the table you are accesing the data from.. meta_upload ... and trying to filter the username from the scan_files - how is that even possible! it is always going to give u error..

it should rather be meta_upload.username ....


likhon3k
  • profile picture
  • Member

Posted 27 January 2015 - 10:49 AM

well.. exactly u will gt error - look @the table you are accesing the data from.. meta_upload ... and trying to filter the username from the scan_files - how is that even possible! it is always going to give u error..

it should rather be meta_upload.username ....

 

I tried both way but faild. I need to clear the concept.

1. meta upload: it contains the file type information.

2. scan_files: new file information will be added by this option and
there are a field which is file type (meta upload table).

3. scan_files have user based file informaiton adding
option. that means, logged in user can access his previous data and can
add new data


Database struture:

user databae:
id, username, password, user_type (1=registered, 2=moderator, 3=admin)

suppose a user logged in. he can get access the sytem with his user_type
and username.