Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

For example :

I have a table name "TEST" and then the value

name | attribute |
 A   |   B       |
 A   |   C       |
 A   |   D       |

if use php

$query = "select * from TEST";

and then i want the code like this $query.remove(attribute,B) ; -> CODE like this(i know this is wrong, i just wanna the similar code like that) I really need that code for my project

Edit: Actually this is my real code:

$query ="SELECT * FROM news_feed
    JOIN friend_list
    WHERE (friend_list.cek='Friend' AND news_feed.emailFrom = friend_list.emailTo AND friend_list.emailFrom = '$email')
    OR (news_feed.emailFrom = friend_list.emailTo AND news_feed.emailFrom = '$email')
    ORDER BY news_feed.tgl desc limit 0,10";

As you can see the $email is the session that runs as the user email and if my friends was 3, then it will create 3 of $email inside the query which is duplicated.

share|improve this question
Why not to use WHERE attribute != 'B'. – Rikesh Jun 12 at 7:20
Do you want to set the value of the attribute column to NULL if the value equals 'B'? Or do you want to remove all the rows where the value of column attribute equals 'B' or...? You really should try to put some effort into clearly explaining what you want. – Ruben Jun 12 at 7:21

closed as not a real question by Jack, PeeHaa 埽, YaK, tombom, Fabio Jun 12 at 9:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

I've rewritten your query a bit. You were mixing old style of joining in WHERE clause and new style using JOIN syntax. Don't do this.

SELECT * FROM news_feed
JOIN friend_list ON news_feed.emailFrom = friend_list.emailTo
WHERE (
(friend_list.cek='Friend' AND friend_list.emailFrom = '$email')
OR 
(news_feed.emailFrom = '$email')
) AND attribute != 'B'
ORDER BY news_feed.tgl desc limit 0,10

And I added AND attribute != 'B', that's how I understood your question. Important is to use parantheses for the other part of the WHERE clause, because you have an OR in there.

share|improve this answer
actually the "B" is what i illustrated, not i ask, the real code that i ask is the $email -> the email that runs through session..the OR (news_feed.emailFrom = '$email') is the major problem . I am sorry my question is very difficult to tell..i will ask with the more complete context on next question..thanks for helping btw – Johan Surya Jun 12 at 9:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.