Jump to content

Question SQL


WASSIm.

Recommended Posts

  • Moderators
i am also new for SQL thingy...

but i used:

executeSQLQuery("SELECT * FROM sqldataName ( column, column) ")

or something like that, anyway you may also check wiki.multitheftauto.com

The syntax is wrong, you probably meant:

SELECT * FROM tableName 

And it will return all rows and columns from a table with the name "tableName"

But before that you probably 1st want to list all tables from the database you are connected on:

SHOW TABLES 

And if you need to list databases:

SHOW DATABASES 

Link to comment

function returnAllData (   ) 
  local data = executeSQLQuery( "SELECT * FROM SQL" ) 
   if ( #data > 0 ) then 
      local table = {   } 
      for _,alldata in ipairs( data ) do 
           table.insert( table, alldata ) 
       end 
   end 
  return table 
end    
Link to comment

i use sqlite with dbConnect and SHOW TABLES not working

addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
    connection = dbConnect("sqlite", "database.db") 
    if (connection) then 
        outputDebugString("Successfully connected to database.db") 
    else 
        outputDebugString("Failed to connect to database.db", 3) 
    end 
end) 
  
addEvent("onPlayerLoadDatabase", true) 
addEventHandler("onPlayerLoadDatabase", root, 
function( ) 
    local query = dbQuery(connection, "SELECT * SHOW TABLES") 
    local data =  dbPoll(query, -1) 
    triggerClientEvent(source, "onClientPlayerLoadDatabase", source, data) 
end) 

Link to comment

It depends on what type of database you have, some say SQL even when they mean SQLite for instance, here's the syntax for all major databases:

MySQL 
SHOW [FULL] TABLES [FROM db_name] [LIKE 'pattern'] 
  
Oracle 
SELECT * FROM dba_tables 
  
MSSQL 
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' 

SQLite is like MySQL basically.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...