Raised This Month: $51 Target: $400
 12% 

Check Two Tables Mysql


Post New Thread Reply   
 
Thread Tools Display Modes
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-03-2016 , 18:02   Re: Check Two Tables Mysql
Reply With Quote #11

As far as your results, you still have %s for IPs in the query. Additionally, as explained above, parts of your query are redundant (namely checking authid's in both tables, since the resulting table of the join is based on authid, thus all authid's match). To add to that, what is expected of data? Will the steam ID always be in one, but not the other, can both have IDs that are not in the other? Will they have the same IDs? What columns will always be the same (this question will help us cut redundancy out of the query)? Important columns are those in the query: Will 'type' and the clients IP always be the same between the two DBs?

INNER JOIN: Only return rows where the ID is in BOTH
LEFT JOIN: The ID must be in the first DB, and if found in 2nd, the info is appended to it.
FULL OUTER JOIN: Returns all rows, regardless of where or not it is in the other DB.

I'm guessing you want LEFT JOIN, since I'd guess that SB tbl has all bans, and some of those also appear in bandisconnected. As a start, run the join query in phpmyadmin with no WHERE statements to see what it returns.

Potentially what you're looking for, although I'd guess you need to change several AND operators to OR operators in your WHERE statement to get what you want, but you havent said much about your data and tables to this point:
Spoiler
__________________
ThatOneGuy is offline
pepe_thugs
Senior Member
Join Date: Aug 2010
Location: Portugal , Braga
Old 01-03-2016 , 22:40   Re: Check Two Tables Mysql
Reply With Quote #12

Thank you for all the attention and help.
I run the query but does not return me any value.
Only returns me value if it is the same "authid" in both tables.
I tried this:

Spoiler



This authid initially had only one of the database and not returned me no value.
Then I added the same authid in another database and has returned me a value.

I did some tests in the plugin and added another query and it looks like it worked but do not know if it will work forever.
You can see me the way I did is reliable?
Attached Files
File Type: sp Get Plugin or Get Source (sourcebans.sp - 32 views - 80.4 KB)
pepe_thugs is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-04-2016 , 00:26   Re: Check Two Tables Mysql
Reply With Quote #13

If you want them banned via either DB, then that is fine, although it will double you client connection queries. I would still work on getting your query right. That will work though, and will block the client if theyre banned via either DB.
__________________
ThatOneGuy is offline
pepe_thugs
Senior Member
Join Date: Aug 2010
Location: Portugal , Braga
Old 01-04-2016 , 08:40   Re: Check Two Tables Mysql
Reply With Quote #14

Quote:
Originally Posted by ThatOneGuy View Post
If you want them banned via either DB, then that is fine, although it will double you client connection queries. I would still work on getting your query right. That will work though, and will block the client if theyre banned via either DB.
And yesterday I had a mistake on my website saying that there were many connections databases. I wanted to do it otherwise.
Is it possible to create a "timer" to go run the second query a few minutes later to not create two connections simultaneously in the database?


This is all because I wanted to use the plugin "MatchBan" and I wanted these bans went to another database. The plugin uses "addban" command and I wanted to create another command (myban) for these bans are separated.
pepe_thugs is offline
pepe_thugs
Senior Member
Join Date: Aug 2010
Location: Portugal , Braga
Old 01-05-2016 , 11:21   Re: Check Two Tables Mysql
Reply With Quote #15

Hello Guys.
I was able to return me values with this query in phpmyadmin:

PHP Code:
SELECT bid
  FROM 
%s_bans
 WHERE 
(    (    type 0
             
AND authid REGEXP '^STEAM_[0-9]:%s$')
         OR (    
type 1
             
AND ip '%s'))
   AND (   
length '0'
        
OR ends UNIX_TIMESTAMP())
   AND 
RemoveType IS NULL
UNION
SELECT bid
  FROM 
%s_bansdisconect
 WHERE 
(    (    type 0
             
AND authid REGEXP '^STEAM_[0-9]:%s$')
         OR (    
type 1
             
AND ip '%s'))
   AND (   
length '0'
        
OR ends UNIX_TIMESTAMP())
   AND 
RemoveType IS NULL 
And it worked very well.
But the plugin not worked.
Dont kick the player when he connects.
It gives me an error in the logs:

Code:
[sourcebans.smx] Query Failed: Column 'bid' cannot be null
Someone can help me please?
Attached Files
File Type: sp Get Plugin or Get Source (sourcebans.sp - 27 views - 80.3 KB)
pepe_thugs is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode