Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Set @num1 := 0, @n2 := 0;
Old 04-28-2010, 09:13 AM Set @num1 := 0, @n2 := 0;
Junior Talker

Posts: 2
Name: ahmed mohammed helmi
Trades: 0
hello guys

i have tried to run this on PHP

PHP Code:
    public function topicsPerdept($q) {

        
$sql "set @num := 0, @n2 := 0;
                SELECT `department_id`, `name`, COUNT(`department_id`) AS 'number_of_thesis',
                @num := 1 AS 'y',
                @n2 := @n2 + 3 AS 'x'
                FROM `thesis` INNER JOIN `department` 
                ON thesis.department_id= department.ID
                WHERE thesis.title LIKE '%
$q%' OR thesis.keyword LIKE '%$q%'
                GROUP BY department_id"


but it dose not work idk why & it gives me this

Reason: Server error MySQL Error - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT `department_id`, `name`, COUNT(`department_id`) AS 'number_of_thesis', ' at line 2
prolabi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-28-2010, 09:38 AM Re: Set @num1 := 0, @n2 := 0;
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://dev.mysql.com/doc/refman/5.0/...ith-alias.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-28-2010, 11:56 AM Re: Set @num1 := 0, @n2 := 0;
Junior Talker

Posts: 2
Name: ahmed mohammed helmi
Trades: 0
Quote:
Originally Posted by chrishirst View Post
i'm sry i can't understand also where is the problem
prolabi is offline
Reply With Quote
View Public Profile
 
Old 04-28-2010, 01:31 PM Re: Set @num1 := 0, @n2 := 0;
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It's probably the way you are using backticks (single quotes) around the alias name.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Set @num1 := 0, @n2 := 0;
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13281 seconds with 12 queries