Hi,
I want to know. How to filter data. I have two mysql table as follow
name:
task_id task my_id
22 aaa 1
22 bbb 1
23 ccc 3
23 ddd 4
24 fff 5

subname::

task_id task my_id
24 fff 1


now my id is 1. I want to show all data from name table except 1 which is present in subname table.any help

Thank you in advance.

Hi,

If the id is coming from auto increment, then it would be difficult to guess which is which. I know it is easy if you are looking at it, but programatically it will be difficult for the script. I mean you can do >22, but that is not the proper way.

You will have to add another column on your table to serve as switch. For example, we can add a column named "status" and this column can have a value of either true or false. This way you can set it to false whenever it is needed using the "task" as parameter. We can filter your data like SELECT * FROM 'table' WHERE status = 'true'. Not only that, we can also set the status to true and false whenever it is needed.

SELECT * FROM name WHERE task_my_id NOT IN (SELECT task_my_id FROM subname)
SELECT * FROM name WHERE task_my_id NOT IN (SELECT task_my_id FROM subname)

sorry i did not posted some information.

My question is according to this table.

1. name

Task_id Member_id Active

1 22 1

2 22 0

3 21 1

4 23 1

5 24 1
here 1 means active and o means not active

now second table
subname:

Task_is member_id
3 22

5 22

Now i want to filter data like this

22 already done some task which are shown in table 2 (subname).
I do not want to show data for 22 member id, which is already done and store in table 2. and other condition those data also which shown in table 1 on the name of 22.

so means my answer would be

task id member id
4 23
I think you got this better now. is there any query for this.

Thanks in advance....

SELECT name.task_id, name.member_id FROM name, subname WHERE name.member_id != subname.member_id

This will get you
3 21 1

4 23 1

5 24 1

I am not sure of what your other condition means. could you clarify your second condition more?

SELECT name.task_id, name.member_id FROM name, subname WHERE name.member_id != subname.member_id

This will get you
3 21 1

4 23 1

5 24 1

I am not sure of what your other condition means. could you clarify your second condition more?

MY member_is is 22. so in name i posted some task. Those wont show me and what ever task present in subname table related to member id 22 that also i want to filter.

so how can filter these data.

so result would be job id 4 memberis will be 23

i got the answer

select * from (select * from name where (member_id!=22 and act!=0)) where task_id NOT IN (SELECT task_id FROM subname where member_id=22)

thanks every one!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.