I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company table for all the company rows
whose ID is NOT linked to in the contact table? Basically, the
Well the directory that houses the database should be writable.
Running the script from command line it gives you write access probably
but it won't work using mod_php because the web server probably can't
write. Try it and give us some feedback.
--
Thodoris
O/H Chris έγραψε:
Markus
2007. 10. 3, szerda keltezéssel 05.21-kor [EMAIL PROTECTED] ezt írta:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company table for all the
Actually you still want to use a join, just an OUTER join instead of an INNER
one.
With an OUTER join, you can get all the rows that match as well as rows where
it doesn't match:
http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join
In the example there, DepartmentID 36 is present in the
Zoltán Németh wrote:
2007. 10. 3, szerda keltezéssel 05.21-kor [EMAIL PROTECTED] ezt írta:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company
- Original Message -
From: Zoltán Németh [EMAIL PROTECTED]
it's not very efficient, but I don't have any better idea. someone else?
Indeed, that sort of query is one of the worst and there is little you can
do to improve it save making sure you have an index on the field of the
you could do a RIGHT OUTER JOIN WHERE the company table is on the right to
show you the companies that do not exist in the contacts table:
SELECT a.name, b.name
FROM contacts a
RIGHT OUTER JOIN company b
ON a.company_id = b.id
WHERE a.name IS NULL;
results:
+--+---+
| name | name
Hi J,
Checkout this,
SELECT * FROM tbl_company where id not in (SELECT companyID from
tbl_contacts)
Regards,
Lasitha Alawatta
Application Developer
Destinations of the World Holding Establishment
P O Box: 19950
Dubai, United Arab Emirates
( Ph +971 4 295 8510 (Board) / 1464 (Ext.)
7
On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company
table.
What is the easiest way to query the company table for all the company
rows
whose
Chris schrieb:
It can't be file permissions, I've even tried to set the database file
to 777... no change at all.
My guess is still permissions. If you try a raw fopen instead of using
pdo, what happens?
?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$fp =
Hi J,
Checkout this,
SELECT * FROM tbl_company where id not in (SELECT companyID from
tbl_contacts)
Brilliant! This is exactly what I was looking for, and is quite
logical/readable! Thanks to everyone for the ideas!
J
Regards,
Lasitha Alawatta
On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi J,
Checkout this,
SELECT * FROM tbl_company where id not in (SELECT companyID from
tbl_contacts)
Brilliant! This is exactly what I was looking for, and is quite
logical/readable! Thanks to everyone for the ideas!
J
I agree with this. Never use a subquery when a join will work. The
optimizer with thank you with performance.
James Ausmus wrote:
On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi J,
Checkout this,
SELECT * FROM tbl_company where id not in (SELECT companyID from
tbl_contacts)
You can also do an outer join and look for NULLS in the key (which means
no match). In some cases it may be more efficient. Ryan
-Original Message-
From: James Ausmus [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 03, 2007 10:00 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED];
I run into this:
http://www.php.net/manual/en/ref.pdo-sqlite.php
while searching for a solution to this exception:
PDOException: SQLSTATE[HY000]: General error: 1
Take a look at it bacause this might be happenning due to version
incompatibilities. For example only sqlite version 3.1.4 and
Hey there,
I've double-checked on three different machines now, and I'm always
getting the same error. All having different versions of PHP, Apache,
PDO and SQLite. So I figure it must be something that I'm doing wrong. I
just can't figure out what it is - and I'm puzzled because I had used
Hi guys,
I have been working on a project for some time now and I'm trying to
make a form that includes (many things and) an edit box with a button by
it. I want this button to open a pop-up window and include a search form
that queries a database and return to its self the result set in a
Hi again Markus,
This is realy confusing but since the command line execution works
for you then the problem should be php configuration for the mod_php. I
came up with this try to edit your php.ini and in case you use
pdo_sqlite extension then change the order of the loaded modules to
[EMAIL PROTECTED] wrote:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company table for all the company rows
whose ID is NOT linked to in the contact
This is not really a database question, but here's something to point
you in the right direction...
In your main page insert this Javascript function:
function sayHello(name) {
alert(Hello +name);
}
In the newly-opened window (it's important that this window has been
opened by the main
Martin Marques wrote:
SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts);
Not ideal as has been mentioned else where in this thread.
Col
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Colin Guthrie wrote:
Martin Marques wrote:
SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts);
Not ideal as has been mentioned else where in this thread.
Col
I think one would have to take into account the DB type being used here.
I can have MySQL and PostgreSQL setup
Markus Wolff wrote:
Chris schrieb:
It can't be file permissions, I've even tried to set the database file
to 777... no change at all.
My guess is still permissions. If you try a raw fopen instead of using
pdo, what happens?
?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$fp
On Thu, 2007-10-04 at 11:23 +1000, Chris wrote:
Robert Cummings wrote:
On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote:
This is only from my own personal testing. Mind you that I have only been
using PostgreSQL for a
year or so. But one problem that I have always ran into with
Robert Cummings wrote:
On Thu, 2007-10-04 at 11:23 +1000, Chris wrote:
Robert Cummings wrote:
On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote:
This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a
year or so. But one problem that I have always
Hi,
I would like to use constructor in PHP4, but how do you make a constructor?
In PHP5, I do like
class ClassName {
function __construct() {
}
}
But PHP4 doesn't have such a thing as __construct()... Reading the
official manual didn't make me understood. Does this mean the very
T K wrote:
Hi,
I would like to use constructor in PHP4, but how do you make a constructor?
Name the function the same as the class.
class ABC {
function ABC() {
//constructor in php4
$this-__construct(); // just call the php5 one.
}
function __construct() {
//constructor in
Hi,
In PHP4, the constructor has the same name as the class.
class ClassName {
function ClassName() {
}
}
T K a écrit :
Hi,
I would like to use constructor in PHP4, but how do you make a constructor?
In PHP5, I do like
class ClassName {
function __construct() {
this is why for backwards compatibility with PHP 4 people usually do
this. Note that if you use public/private/protected it probably will
not work on PHP 4
?php
class Foo
{
function __construct($params)
{
$this-Foo($params);
}
function Foo($params)
{
Robert Cummings wrote:
On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote:
This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a
year or so. But one problem that I have always ran into with MySQL is that when JOIN'ing tables
that have large data
Thanks guys!
I got the same name trick for PHP 4 class constructor.
All the best,
T
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I would also suggest to limit yourself to things you actually need not
to select the whole table.
Aleksandar
Jim Lucas wrote:
Colin Guthrie wrote:
Martin Marques wrote:
SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts);
Not ideal as has been mentioned else where in
Aleksandar Vojnovic wrote:
I would also suggest to limit yourself to things you actually need not
to select the whole table.
In this case you can't because you're looking for records that exist in
one table that don't exist in another.
Apart from looking at the whole table in each case how
It seems you missed my point :) if you would need all the data then
select them all, but if you need only partial data from the table then
you could limit yourself to that specific columns. I doubt everybody
need everything all the time. True?
Aleksandar
Chris wrote:
Aleksandar Vojnovic
Aleksandar Vojnovic wrote:
It seems you missed my point :) if you would need all the data then
select them all, but if you need only partial data from the table then
you could limit yourself to that specific columns. I doubt everybody
need everything all the time. True?
Ahh - you meant the
35 matches
Mail list logo