Jump to content

Setting a record in a table to be the default record.


Jabop

Recommended Posts

[pre]

Images Table

ID SubmissionType SubmissionID FileName Ext Uploader Default

[/pre]

 

When a user uploads the images, the info is posted into the table. Submission ID will be where the image is being displayed. My question is, how can I insert the Default record to 1 for the FIRST record inserted in the table with the SubmissionID of X.

 

Example:

 

95316843no1.gif

 

I want to be able to check to see if the SubmissionID already has a record with a Default value of 1, and if not, make it 0.

 

 

I've been looking at a lot of sql help online, and can't find what I need. :(

Also, right now I am just GROUPING by the SubmissionID. Here is my SQL.

 

SELECT 
		n.ID,
		n.Category,
		n.Title,
		n.Description,
		n.Body,
		n.CreatedBy,
		n.Time,
		u.UserName, 
		i.SubmissionType,
		i.SubmissionID,
		i.FileName,
		i.Ext
		FROM news AS n 
		LEFT JOIN users AS u 
		ON u.ID=n.CreatedBy 
		LEFT JOIN uploaded_images AS i
		ON n.ID=i.SubmissionID GROUP BY n.ID
		ORDER BY n.Time 
		DESC LIMIT ".$Lim.",5"

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.