I have to read 25 usernames from a single users row
than display to that user the 25 profiles.
I assume this is possible with a subquery right?
Now do i have to make 25 columns 1 for each username or
could it read user1 user2 user3 ? and how please.. Thanks much
Can you explain a little more about how these usernames are currentlystored in your database, and why you need to make them columns? Sounds like they're better suited to being rows, instead ofcolumns.|||
i have an infinite number of rows with primary key username
each column needs to store up to 25 usernames who sent a message
than im thinking a subquery can display the info for each username for that exact person.
info to be display is picture and some things about themself
How... im still trying to figure out.
i have this in one table
Username - primary key
user1, user2 user3 as columns - for each person that made an action on that users page
store them in a column
My question is: There a simplier way to read these users instead of making a bunch of columns for each user who made an action?
|||
Guys would making subtables cause trouble in the long run?
If i make a sub table for every user?
|||ck1mark wrote: My question is: There a simplier way to readthese users instead of making a bunch of columns for each user who madean action?
Hi,
Yep, there is. Any time you have an inclination of creating a tablewith numbered fields like that, it is a huge warning flag that thestructure is not normalized. Almost certainly, a better way is to havea Message table (I'm guessing here on what table names will make sense)that has a MessageID and whatever other fields you need to have tostore whatever information.
Then you have a child table with a structure something like this:
UserID -- Could be the user name or a artificial primary key
MessageID -- A foreign key into the Message table
This way storage is more efficient, you don't have to worry about theone message you'll occasionally get that has 26 users, and SQL isdesigned to handle related tables like this.
Make sense?
Don
|||
help me write this please im having trouble
i need to insert the select statement values
INSERT INTO table1
VALUES username, photo1
(SELECT r.username, photo1
FROM table2 r, table3 p
WHERE r.username = '" & user.identity.name & "' AND r.username = p.username)
|||You might want to check Books Online for the syntax. But it should besomething like this (untested, so may still need some tweaking):
INSERT INTO table1 (username, photo1)
(SELECT r.username, photo1
FROM table2 r, table3 p
WHERE r.username = '" & user.identity.name & "' AND r.username = p.username)
Does that work? If not, what troubles are you having?
By the way, this is dangerous code because of SQL injection. Usinguser.identity.name may be safe, but only if you've made sure the namedoesn't have any bad stuff in it. It's always better to useparameterized queries.
Don
No comments:
Post a Comment