TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   PHP Get data from multi table (http://www.talkphp.com/advanced-php-programming/5557-php-get-data-multi-table.html)

shoaibmunir 08-29-2010 10:00 AM

PHP Get data from multi table
 
i'm working on ERP Solutions and want to inform if any one have unread notification and i want send one email daily if anyone not read notification. one email in one day each member who have unread notifications.

My Query

"select n.*, i.* from ew_notifications n, ew_inform i where n.authorid<>i.authorid and i.senddate<>'$todatdate' "


if($resords>0){

insert into ew_inform (authorid, senddate) value('{$resords['authorid']}', '$todatdate')

}


error this my query showing again tha member that exiting in ew_inform table i just want that pplz come who dont exsit in ew_inform table in current date

Krik 09-13-2010 09:12 PM

I can't make heads or tales of how the tables you provided are constructed to give you an accurate query, but if you are looking to query 2 tables you usually use a LEFT JOIN.

PHP Code:

$sql "
    SELECT *
    FROM ew_inform
    LEFT JOIN ew_notifications on ew_notifications.authorid = ew_inform.authorid
    WHERE ew_inform.senddate != '" 
$todatdate "'
"


You have to join them on a common identifier.

Now I get the sense that you may be checking if one table doesn't have a particular "authorid" with today's date. If that is the case I believe 2 query will be needed.


All times are GMT. The time now is 03:36 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0