Jump to content


Photo

Filter, in the query..


  • Please log in to reply
4 replies to this topic

#1 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 17 July 2006 - 06:06 PM

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
(If something is wrong, please tell me. I'm learning this language. Thank you)

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 July 2006 - 06:12 PM

Sounds like a simple left join... do you already have some sort of query that doesn't work as expected?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 17 July 2006 - 06:33 PM

SOLVED!!!!!!

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
(If something is wrong, please tell me. I'm learning this language. Thank you)

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 18 July 2006 - 07:55 AM

Could you post the solution?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 19 July 2006 - 07:57 PM

Sure!! =)

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

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users