How to query a MYSQL database for all values within an array -
i have mysql database with users , activity table. user table containing user info , activity table containing messages users activity on site (similar facebooks news feed).
within users table have stored array of friends commas separated string. (friend_list)
i trying select using mysql joins messages friends in friends list , current user , order them activity timestamp.
i thinking this...
$query=mysql_query("select * users,activity users.user=activity.user or //### activity.user equal 1 of users.friend_list array values ### order activity.timestamp")or die(mysql_error());
its tough 1 describe. hope it.
i dont know syntax compare activity.user against array of values (users.friend_list)
its simple when know how. ideas on fantastic.
fix database schema. mysql has no notion of "array of values". should use tables, columns , rows describe data , relationships between entities.
you create friends
table can store ids of 2 people being friends. it's matter of doing join.
create table friends ( user1 integer not null, user2 integer not null, primary key (user1, user2) );
Comments
Post a Comment