How to implement "share with network" functionality using LAMP [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have these tables, members, my_connections, my_thoughts.
How do I add a "Share with your network" functionality where a member can share their thoughts with people they are connected to in my_connections.

Easy. In the my_thoughts table add another column - shared, which will be a boolean (I use tinyint, 0 or 1). Then, to select all thoughts that have been shared by my friends:
select * from
my_connections c
join my_thoughts t on (c.connection_id=t.my_id)
where
c.my_id=<insert my ID here>
and t.shared=1
That's assuming that table my_connections has the columns my_id and conection_id, and that table my_thoughts has a column my_id.

Related

How to make data zig zag from a,a,a,b,b,b to a,b,a,b,a,b using php or sort? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 19 days ago.
Improve this question
How to make data zig zag from a,a,a,b,b,b to a,b,a,b,a,b using php or sort?
because i'm try usort but it can't be done
We can certainly do it in MySQL using sort. Here is one possible way to do it. But do try to get the hang of the row_id user varible trick yourself.
create table test(v char(1));
insert test values('a'),('a'),('a'),('b'),('b'),('b');
select v from
(select v ,#a_id:=#a_id+1 as row_id from test,(select #a_id:=0) t1 where v='a'
union
select v ,#b_id:=#b_id+1 as row_id from test,(select #b_id:=0) t2 where v='b') t
order by row_id,v;

Join multiple tables in php codeigniter [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can join 2 tables with another by same fields in php codeigniter
Eg.
I have 3 table
student with adm_number
Staff with pe_numbber
And bookhistory with usernumber
How can join student and staff table to bookhistory
simultaneously by comparing with usernumber
You can achieve your target as:
$this->db->select();
$this->db->from('student');
$this->db->join('staff', 'student.adm_number = staff.pe_numbber');
$this->db->join('bookhistory', 'student.adm_number = bookhistory.usernumber');

MySQL Join Users table to Groups table, find users not in any of selected groups [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How do I write a query that takes a list of group ids (could be 1, could be 10, etc) and gets the users who are not in ANY of those groups?
We are using Doctrine, but we can't even figure out how to do it in raw SQL.
It's okay to have PHP generate part of the query if we need to do multiple joins/conditions etc based on how many ids are provided.
If my general assumptions about your table structure are correct, I believe something like this should work:
SELECT *
FROM users
WHERE user_id NOT IN (
SELECT DISTINCT user_id
FROM user_groups
WHERE group_id IN ([your group list])
);

SQL - Copy and replace data from another table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm having trouble with copying data from a table with the same structure to another table with the same first column. I have 2 tables. One is STANDARD, the other one is called W2.
I then choose a name, for example Test.
I want to copy the values except for the name from the STANDARD table into the W2 table. So replace those values. As you can see the values of Test are different in the W2 table. I want to replace those values with the values from STANDARD.
STANDARD:
W3:
Can someone please help me out?
Try this
Update w2 set
Maandag = (SELECT Maandag From STANDARD a where w2.id = a.id),
Dinsdag = (SELECT Dinsdag From STANDARD a where w2.id = a.id)
Etc....
Where w2.id = 'test'

Combine Two Column Fields From ONE Table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I made a new question cause I don't understand the other answers.
I want to get clear here.
I have a table named "experiences".
It has THREE FIELDS: id, experience_name, years.
I want to combine the TWO COLUMNS : experience_name and year and name it like.. experience
Then i want to make a new table and name it resume_experiences and put the COLUMNS id and experience
can you guys please help me..
How am i gonna do it?
OUTPUT SHOULD BE:
table name: resume_experiences
fields: ID | EXPERIENCE
Try this:
INSERT INTO resume_experiences
(id, experience)
SELECT id, CONCAT(experience_name, ' ', CONVERT(years,UNSIGNED))
FROM experiences
CREATE TABLE IF NOT EXISTS `resume_experiences `
SELECT `id`, CONCAT(`experience_name`, ' ', `years`) AS `experience`
FROM `experiences`;

Categories