Hi everyone and thanks for looking.
I have a webform that hooks into a SQL Server 2005 database. Aside from submitting flat data, I’m using two select statements. The first populates a drop down list with the names of other users from the database.
SELECT Firstname + ' ' + LastName
FROM KB_XMod_Modules
WHERE FormID=3
This is fine but I also need to update other users records to show when they’ve been selected by the current profile. Think of it as ‘John likes Paul’ and on Paul’s record it should show ‘Paul is liked by John’.
I’ve been struggling and the closest I’ve got is having this second statement on the form…
SELECT Firstname + ' ' + LastName
FROM KB_XMod_Modules
WHERE LikedByID = 'Current Record ID'
This kind of works but the problem is that it won’t display on ‘Paul’s’ record that he’s ‘Liked by John’ until I’ve opened up and saved Paul’s record. I’m going to be working with several hundred records so this can’t be done manually. I need a way of being able to directly update Paul when I save John.
Ideally I think I’d like to bolt on an UPDATE to the first statement that populates the drop down list with users names but also updates the related record on submission but don’t think this is possible.
I’m just getting into SQL and finding it difficult to work out the best way to do this…
Thanks again.
Consider having an ID in your dropdownlist like:
Your dropdown can then remember which person you’re on:
Let’s pretend that Paul likes John. When you’re saving a ‘like’, you can :
Also consider whether a person could be liked by more than one other person. In that case you’d need to refactor your database design:
You’d then need to only: