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. :(

Link to comment
Share on other sites

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"

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.