Jump to content

Where clause error


unemployment

Recommended Posts

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 'WHERE `approved_date` > 1304300469 ORDER BY `approved_date` DESC ' at line 311

 

WHERE `approved_date` > ${time}
ORDER BY `approved_date` DESC
LIMIT 20 

Link to comment
Share on other sites

The problem is right before the WHERE in your query.

 

I actually am using multiple unions before the where and I think that is the problem.  I should probably put the where in the unions.

 

But now I'm getting a new error. #1052 - Column 'approved_date' in where clause is ambiguous

 

One of the unions is posted below.

 

(

            SELECT

                users2.id,

                users2.firstname,

                users2.lastname,

                users2.username,

                '' AS industry,

                '' AS stage,

                '' AS companytag,

users2.gender,

                users3.accounttype,

                users3.country,

                users3.state,

                users3.city,

                UNIX_TIMESTAMP(`partners3`.`approved_date`) AS `approved_date`,

                users3.id AS FeedId,

                users3.firstname AS FeedFirstName,

                users3.lastname AS FeedLastName,

                users3.username AS FeedUserName,

                '' AS action_id,

                '' AS details

            FROM users

            INNER JOIN partners ON partners.user_id = users.id AND partners.approved = 1

            INNER JOIN users users2 ON users2.id = partners.friend_id

            INNER JOIN partners partners3 ON partners3.user_id = users2.id AND partners3.approved = 1

            INNER JOIN users users3 ON users3.id = partners3.friend_id

            WHERE users.id = ${uid}

            AND `approved_date` = ${time}

        )

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.