Jump to content

Filter, in the query..


Darkness Soul

Recommended Posts

Yo,

That's my problem:

I have two table:
1. users - All user data
2. banish - user id and blob

My query will show me all not-baned users, so, I need to list the users from table 1, testing the table 2, and showing only who isn't in the second table..

simple like that, hard like itsef.. never do something like it..

thanks,

D.Soul
Link to comment
Share on other sites

[b]SOLVED!!!!!![/b]

Thanks anyway.. =))))

D.Soul

~~~~~~~~~~

I'm editing this post:

My group leader (don't know how is called who is the project manager) give me a bad new.. this sql that I have the problem, use six table. Let me join you at the real-query problem..

I have that six table:

1. User data, all data
2. Task, all info about the task
3. Finished Task, info about the task that was finished with some manager entrys..
4. Events, like task
5. Finished Events, like finished task
6. Checked Users

Ok, my query will return ID and NAME from table 1, I've built like it:

Users in t1, where have an entry in t2, where have this entry finished in t3, where have an entry in t4, where have this entry finished in t5, where is not checked yet in t6*

*this one is the problem i've posted before

This is an AND case, t2>t3 AND t4>t5, right?

Now i ned an OR case.. to list it, t2>t3 OR t4>t5 OR both..

How i do this or inside the joins condition??? And how i correct the t6 problem without subquery?

Thanks,

D.Soul
Link to comment
Share on other sites

Sure!! =)

[code]SELECT
tbC.nome_fantasia, tbC.id

FROM
tbClientes_PJ AS tbC

LEFT JOIN
tbPastas_Andamento AS tbPN
LEFT JOIN
tbPastas_Andamento_Realizadas AS tbAN
ON
tbAN.id_atividade = tbPN.id
ON
tbPN.id_cliente = tbC.id

LEFT JOIN
tbPastas_Atividade AS tbPA
LEFT JOIN
tbPastas_Atividade_Realizadas AS tbAR
ON
tbAR.id_atividade = tbPA.id
ON
tbPA.id_cliente = tbC.id

LEFT JOIN
tbAprovados AS tbA
ON
tbA.id_cliente = tbC.id

WHERE
(
tbA.id_cliente IS NULL
)
AND
(
(
tbPA.tipo_cliente =1
AND
month( tbAR.data_alterada_inicial ) =7
)
OR
(
tbPN.tipo_cliente =1
AND
month( tbAN.data_alterada_inicial ) =7
)
)

GROUP BY
tbC.nome_fantasia
[/code]

D.Soul
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.