WASSIm. Posted July 13, 2014 Share Posted July 13, 2014 hi guys, i working for Sqlite browser panel but i don't know get all data from sql with tables please if anyone know it tell me Link to comment
_DrXenon Posted July 13, 2014 Share Posted July 13, 2014 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 Link to comment
Moderators Citizen Posted July 13, 2014 Moderators Share Posted July 13, 2014 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
#DRAGON!FIRE Posted July 14, 2014 Share Posted July 14, 2014 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
WASSIm. Posted July 14, 2014 Author Share Posted July 14, 2014 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
Mr_Moose Posted July 14, 2014 Share Posted July 14, 2014 You have SELECT * SHOW TABLES in your code, it should only be SHOW TABLES if you want to list all tables in your database. Link to comment
WASSIm. Posted July 15, 2014 Author Share Posted July 15, 2014 debug show me this: dbPoll failed near "SHOW": syntax error Link to comment
Saml1er Posted July 15, 2014 Share Posted July 15, 2014 "SELECT * SHOW TABLES" As you can see here you have spaces SHOW TABLES. Not sure but I don't think so you can use spaces and it should be "SELECT * FROM MyTableName" Link to comment
Arnold-1 Posted July 15, 2014 Share Posted July 15, 2014 i don't have a huge knowledge about SQL, but i think "SELECT * FROM *" would work to get ALL the data. Link to comment
Mr_Moose Posted July 15, 2014 Share Posted July 15, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now