I need to write an inner join for a small messaging app. In my sql experience I haven't had to do many inner joins so I'm kinda cloudy on it.
I have the following two tables and I want to select ALL columns, but I want to declare each column in the select rather than justing using "select all".
So that the same message can be sent to multiple users without having to have redundant entries for the content and subject of the message, I've split the tables into two so that there can be many entries for the messages, but if the many messages have the same content, they all point to the same content record. So (tbl_member_messages) is MANY to (tbl_member_message_content) One. The join will be on "message_content_id" as that is the key that is shared between tables.
-----------------------------------------
tbl_member_messages
message_id (int-identity-pk)
message_content_id (int-fk)
message_sender_user_name (varchar-30)
message_recipient_user_name varchar-30)
message_is_new (bit)
message_is_read (bit)
message_is_replied (bit)
message_is_flagged (bit)
message_is_urgent (bit)
message_is_sender_deleted (bit)
message_is_recipient_deleted (bit)
message_sent_date (datetime-null)
message_read_date (datetime-null)
message_referrer_message_id (int-null)
message_sender_ip (varchar-15)
tbl_member_messages_content
message_content_id (int-identity-pk)
message_subject (varchar-50)
message_body (varchar-1000)
-------------------------------
Can someone help me get the SQL statement setup for this?
I have the following two tables and I want to select ALL columns, but I want to declare each column in the select rather than justing using "select all".
So that the same message can be sent to multiple users without having to have redundant entries for the content and subject of the message, I've split the tables into two so that there can be many entries for the messages, but if the many messages have the same content, they all point to the same content record. So (tbl_member_messages) is MANY to (tbl_member_message_content) One. The join will be on "message_content_id" as that is the key that is shared between tables.
-----------------------------------------
tbl_member_messages
message_id (int-identity-pk)
message_content_id (int-fk)
message_sender_user_name (varchar-30)
message_recipient_user_name varchar-30)
message_is_new (bit)
message_is_read (bit)
message_is_replied (bit)
message_is_flagged (bit)
message_is_urgent (bit)
message_is_sender_deleted (bit)
message_is_recipient_deleted (bit)
message_sent_date (datetime-null)
message_read_date (datetime-null)
message_referrer_message_id (int-null)
message_sender_ip (varchar-15)
tbl_member_messages_content
message_content_id (int-identity-pk)
message_subject (varchar-50)
message_body (varchar-1000)
-------------------------------
Can someone help me get the SQL statement setup for this?
