Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

..WHERE t1.a IN( t1.b );
Definition:
I have a table t1, with collumns id, id_parent, and name.
This t1.id_parent could be NULL or contain some other t1.id.
Purpose is to make a expandable and collapsable treeview.
Now it could be handled by using subquery's, but the server
doesn't allow to use these. Older mysql version. Thats a fact, i
can not change it.  :(

[b]Problem:[/b]
Actualy there are lots of left join's etc in the real query,
it's huge.
Simply put, left out all irrelevant things, it looks like
this.--------
SELECT t1a.id, t1a.id_parent, t1a.name
FROM t1 AS t1a, t1 AS t1b
WHERE NOT ( t1a.id_parent IN(t1b.id) )
OR t1.id_parent IS NULL;
--------
Old query was: --------
SELECT id, id_parent, name
FROM t1
--------

[b]Question:[/b]
I just want to have all [b]id[/b]'s
of the records from [b]t1[/b]
having
no [b]id_parent[/b] pointing to them,
[u]or[/u] that who are [b]NULL[/b].

I dont see it.  :blink: But looked everywhere.
though http://dev.mysql.com/doc/mysql/en/R...subqueries.html has
some info about this. Also see second-to-last post.

:) live & love life 2b happy !!

----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
barryke
04-22-04 01:34 PM


Re: ..WHERE t1.a IN( t1.b );
Solved.

This way:

--------
SELECT
relatie.id AS 'id',
relatie.name AS 'name',
FROM relatie
LEFT JOIN relatie AS `relatie_parent`  ON
relatie.id_parent  = relatie_parent.id
WHERE
( relatie_parent.id IS NULL
OR relatie.id_parent IS NULL
)
--------

if the LEFT JOIN cant join some relation's id_parent to an other
relation's id, it will make this id NULL. So i joint them and
only showed the blanc

:) live & love life 2b happy !!

----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
barryke
04-29-04 04:10 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:03 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.