Code: Select all
$sql = 'SELECT t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy'
etc.
Code: Select all
$sql = 'SELECT t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy
t.table_thingy'
etc.
Code: Select all
'SELECT '.POSTS_TABLE.'.post_id, '.POSTS_TABLE.'.post_text, '.POSTS_TABLE.'.post_deleted, '.POSTS_TABLE.'.topic_id, '.POSTS_TABLE.'.post_date, '.POSTS_TABLE.'.user_id, '.USERS_TABLE.'.user_name, '.USERS_TABLE.'.user_id, '.USERS_TABLE.'.user_sig, '.USERS_TABLE.'.dominant_group, '.USERS_TABLE.'.post_count, '.GROUPS_TABLE.'.group_colour, '.GROUPS_TABLE.'.group_image, '.GROUPS_TABLE.'.group_id, '.USERS_TABLE.'.user_avatar, '.EDITS_TABLE.'.edit_id, '.EDITS_TABLE.'.last_edit_user, '.EDITS_TABLE.'.last_edit_time
FROM '.POSTS_TABLE.'
LEFT JOIN '.USERS_TABLE.' ON '.POSTS_TABLE.'.user_id = '.USERS_TABLE.'.user_id
LEFT JOIN '.GROUPS_TABLE.' ON '.USERS_TABLE.'.dominant_group = '.GROUPS_TABLE.'.group_id
LEFT JOIN '.EDITS_TABLE.' ON '.POSTS_TABLE.'.post_id = '.EDITS_TABLE.'.post_id
WHERE '.POSTS_TABLE.'.topic_id='.$topic_data['topic_id'].' '.$where.'
ORDER BY post_date ASC'
Glorius Hole wrote: ... Why do the table collums have a prefix in them when you select?
What's with the t.? I just don't get it.Code: Select all
$sql = 'SELECT t.table_thingy t.table_thingy t.table_thingy t.table_thingy t.table_thingy t.table_thingy' etc.
Code: Select all
$sql = 'SELECT t.* FROM table t'
Code: Select all
$sql = 'SELECT t.* FROM table AS t'
Code: Select all
$sql = "SELECT
a.story_id,
a.story_intro,
a.story_body,
u.username AS author_username,
u2.username AS informant_username
FROM
". ARTICLES_TABLE ." a,
". ARTICLES_TOPICS_TABLE ." t
LEFT JOIN
". USERS_TABLE ." u ON (a.author_id = u.user_id)
LEFT JOIN
". USERS_TABLE ." u2 ON (a.story_informant = u2.user_id) WHERE a.story_id = '$story_id'";
Code: Select all
$sql = "SELECT
f.staff_id,
COUNT(DISTINCT e.exam_id) AS total_exams
FROM
". EXAMS_TABLE ." e