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
How can I do this correctly?
INSERT INTO tbl_task (`Assignedby`,`userID`)
SELECT ID FROM tbl_users WHERE UserName='$_GET[u]',
SELECT ID FROM tbl_users WHERE UserName='$_GET[at]'
Assuming you want to insert one row with two columns, I think you might want this:
INSERT INTO tbl_task(`Assignedby`, `userID`)
SELECT (SELECT ID FROM tbl_users WHERE UserName='$_GET[u]'),
(SELECT ID FROM tbl_users WHERE UserName='$_GET[at]');
Related
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 2 years ago.
Improve this question
I have query for to get data following :
select a from REPLACE(M,',','')TABLE;
I want to get all the data from table along with M column content replce , with space.
You select from the table. What you select belongs in the SELECT clause:
SELECT t.*, REPLACE(m, ',', '') FROM mytable t;
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 2 years ago.
Improve this question
As the title suggests, trying to take the count or possibly distinct count of a column, we call it year, to count the number of a years for an individual or populated ID and place it another column in the same table. Here is an idea of what I have so far and we want to update the table. Thank you.
Join group table to updated table directly:
UPDATE outputtable O JOIN
(SELECT personID, COUNT(DISTINCT year) AS countYear
FROM outputtable GROUP BY personID) temp ON O.personID=temp.personID
SET O.N=temp.countYear
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 2 years ago.
Improve this question
CREATE TRIGGER NOTICE_ISSUE
AFTER INSERT ON MEMBERS
FOR EACH ROW
INSERT INTO NOTICE (Ssn,LSSN,NOTICE_TYPE) VALUES
((SELECT Ssn from MEMBERS WHERE CURDATE() = NOTICE_DATE),
(SELECT LIB_SSN from MEMBERS WHERE CURDATE() = NOTICE_DATE),'RENEW YOUR MEMBERSHIP');
You are duplicating the select query, it would be better like this:
CREATE TRIGGER NOTICE_ISSUE AFTER INSERT
ON MEMBERS
FOR EACH ROW
INSERT INTO NOTICE (Ssn,LSSN,NOTICE_TYPE)
SELECT Ssn, LIB_SSN, 'RENEW YOUR MEMBERSHIP'
FROM MEMBERS
WHERE CURDATE() = NOTICE_DATE
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 6 years ago.
Improve this question
i want to select two columns from database id and password
and want to use those two columns data in update query
example
select id , pass from table
second update query
update table set password2=password_get_from select_query where id=id_get_from_select_query
Try something like.
update table_one as A
inner join table_two AS B on (A.id = B.id)
set A.some_column = B.some_column,
A.another_column = B.another_column
where blah
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 6 years ago.
Improve this question
I have one table with 3 fields e.g.
Name, Team Name, Player_Number
there is multiple team and I want to fetch 2 member from each team.
Please share with fast solution.
Try this
select * from TableName s where (select count(*) from TableName a where a.TeamName = s.TeamName and a.Player_Number >= s.Player_Number) <= 2