Reputation: 5717
The following SQL query isn't working. I think the error is on the first line.
SELECT
SUBSTRING(tbl_news.comment, 1, 250) as tbl_news.comment,
tbl_news.id, tbl_news.date, tbl_news.subject, tbl_users.username
FROM
tbl_news
INNER JOIN
tbl_users ON tbl_news.creator = tbl_users.id
ORDER BY
date DESC
Upvotes: 0
Views: 884
Reputation: 332521
Use:
SELECT SUBSTRING(tn.comment, 1, 250) AS "tbl_news.comment",
tn.id,
tn.date,
tn.subject,
tu.username
FROM tbl_news tn
JOIN tbl_users tu ON tu.id = tn.creator
ORDER BY tn.date DESC
Using single quotes on the column alias also worked for me on SQL Server:
SELECT SUBSTRING(tn.comment, 1, 250) AS 'tbl_news.comment',
tn.id,
tn.date,
tn.subject,
tu.username
FROM tbl_news tn
JOIN tbl_users tu ON tu.id = tn.creator
ORDER BY tn.date DESC
Upvotes: 1
Reputation: 23289
Try this:
SELECT SUBSTRING(tbl_news.comment, 1, 250) as comment,
tbl_news.id, tbl_news.date, tbl_news.subject, tbl_users.username
FROM tbl_news
INNER JOIN tbl_users ON tbl_news.creator = tbl_users.id
ORDER BY date DESC
Upvotes: 1
Reputation: 18215
SELECT SUBSTRING(tbl_news.comment, 1, 250) as comment,
tbl_news.id, tbl_news.date, tbl_news.subject, tbl_users.username FROM tbl_news
INNER JOIN tbl_users ON tbl_news.creator = tbl_users.id
ORDER BY date DESC
Upvotes: 1
Reputation: 3044
I don't think your alias as tbl_news.comment
is allowed to have a dot in it. What error are you getting? What flavor of SQL is it? Thanks.
Upvotes: 4