Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1529 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

SQL problem (left join related most likely)

Thread title: SQL problem (left join related most likely)
Closed Thread    
    Thread tools Search this thread Display Modes  
01-01-2008, 10:01 PM
#1
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old  SQL problem (left join related most likely)

I am making a polling script, I have it able to get the top 3 items voted for. I am trying to left join the item data with the result data with this query
Code:
SELECT `votes.poll_id` AS `votes_pollid`,
COUNT(`item_id`) AS `count`,
`item_id`,
`items.*` 
FROM `votes` 
LEFT JOIN `items` ON `votes.id`=`items.poll_id` 
WHERE `votes.poll_id` = '1'  
GROUP BY `item_id` 
ORDER BY `count` DESC 
LIMIT 3;

It tels me that votes.poll_id doesn't exist. That is simply not true, I can call votes.poll_id in a separate query and it comes up.

01-17-2008, 09:27 PM
#2
.deMoN. is offline .deMoN.
Status: I'm new around here
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 23
iTrader: 0 / 0%
 

.deMoN. is on a distinguished road

  Old

Are you using MySQL or Postgres, or ?

try not using the `'s around the table.field accessor, but rather just putting it around the field. It might be trying to find a table called 'votes.poll_id' literally.

Did the error message by any chance give you a char. number?

01-18-2008, 06:07 AM
#3
penguinburner is offline penguinburner
Status: Junior Member
Join date: Sep 2007
Location: Australia
Expertise: Programming, UX
Software:
 
Posts: 80
iTrader: 3 / 100%
 

penguinburner is on a distinguished road

  Old

table.field doesn't need backticks around it (it'd search for table.table.field)

01-18-2008, 01:25 PM
#4
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

I got this solved on talkphp a while ago. Thanks anyway.

Im using mysql

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed