Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

PLz Plz help me..........

Codes here !

Moderators: macek, egami, gesf

PLz Plz help me..........

Postby Hassan » Sun Jun 02, 2013 6:52 am

Suppose i have a table tbl_sales where data are:
sales_cart_id sales_product_id
0 11
0 12
0 13
1 14
1 19
1 20
.
n 5
n 7
n 12
now i need all the sales_product_id where 12 has in group 0,1,...n .
In this case result will be 0 has 11,0 has 13,n has 5,n has 7. but not 14, 19, 20 because in 1 group there is no 12.
Hassan
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Jun 02, 2013 6:36 am

Re: PLz Plz help me..........

Postby developerahusain » Sun Jun 02, 2013 8:55 am

Do come clear hassan. I will try to resolve your problem

regards
developerahusain
developerahusain
New php-forum User
New php-forum User
 
Posts: 44
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow

Re: PLz Plz help me..........

Postby Hassan » Sun Jun 02, 2013 9:40 am

$sql1 = "SELECT sales_cart_id
FROM tbl_sales
WHERE sales_product_id = $varf
GROUP BY sales_cart_id";
//@to avoid Warning
$result1 = @mysql_query($sql1) or die("Error in Select Query in CheckUserById Function" . mysql_error());
while($record1 = mysql_fetch_object($result1)){
$raj=$record1->sales_cart_id;
i have just finished it....thx
$sql = "SELECT sales_product_id,sales_cart_id
FROM tbl_sales
WHERE sales_product_id != $varf AND sales_cart_id = $raj
GROUP BY sales_product_id";
//@to avoid Warning
$result = @mysql_query($sql) or die("Error in Select Query in CheckUserById Function" . mysql_error());
while($record = mysql_fetch_object($result)){
$raj1=$record->sales_cart_id;
$raj=$record->sales_product_id;
echo $raj1. '<br />';
echo $raj.'<br />';
}
}
Hassan
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Jun 02, 2013 6:36 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron