Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43260
Total Topics: 7518
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 267
Total: 268

Author Topic: How do you string these two queries to  (Read 4741 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
How do you string these two queries to
« on: August 05, 2016, 12:28:49 am »
Hi there,

The following code does exactly what I want but I was wondering if there's a cleaner, neater way to do it:

Code: [Select]
$dbresult = db_query("
SELECT
ID_MEMBER
FROM {$db_prefix}store_transactions
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);

$found = db_affected_rows();
mysql_free_result($dbresult);

// If the record exists
if ($found == true)
{
$dbresult = db_query("
SELECT
ID_MEMBER
FROM {$db_prefix}store_group_log
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);

$found = db_affected_rows();
mysql_free_result($dbresult);

// If the record exists
if ($found == true)
echo 'Something found';
else
echo 'Nothing found';
}

The logic is, see if the current member is found in store_transactions, if yes, then see if the current member is found in store_group_log.

Now, is there a way to combine the two?

=== Update (failed attempted) ===

I tried this following but did not work:

Code: [Select]
$dbresult = db_query("
SELECT t.ID_MEMBER, i.ID_MEMBER
FROM ({$db_prefix}store_transactions AS t, {$db_prefix}store_group_log AS i)
WHERE t.ID_MEMBER = $ID_MEMBER AND i.ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);

$found = db_affected_rows();
mysql_free_result($dbresult);

        // If the record exists
if ($found == true)
echo 'Something found';
else
echo 'Nothing found';

« Last Edit: August 05, 2016, 12:42:32 am by shuban »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: How do you string these two queries to
« Reply #1 on: August 05, 2016, 06:35:53 am »
Replace this lien
t.ID_MEMBER = $ID_MEMBER AND i.ID_MEMBER = $ID_MEMBER
With
t.ID_MEMBER =   i.ID_MEMBER AND t.ID_MEMBER = $ID_MEMBER
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/
Useful Useful x 1 View List

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: How do you string these two queries to
« Reply #2 on: August 05, 2016, 12:40:44 pm »
Thank you

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
3814 Views
Last post May 14, 2009, 11:24:12 am
by tofo
3 Replies
3920 Views
Last post August 19, 2014, 08:30:52 am
by SMFHacks

+- Recent Topics

No thumbnails on new uploads by Tonyvic
Today at 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal