diff --git a/README.md b/README.md
index c973972..a98407f 100644
--- a/README.md
+++ b/README.md
@@ -61,18 +61,31 @@ string(9) "Customers"
```
-How to retrieve the query's tables:
+How to retrieve the query's tables (including aliases used in the query):
```php
$parser->getAllTables();
```
Output
```
array(1) {
- [0]=>
- string(9) "Customers"
+ [0]=> string(9) "Customers",
+ [1]=> string(5) "Alias"
+}
+```
+
+
+How to retrieve the query's tables (without aliases used in the query):
+```php
+$parser->getAllTablesWithoutAliases();
+```
+Output
+```
+array(1) {
+ [0]=> string(9) "Customers"
}
```
+
### Fields
How to retrieve the query's fields:
```php
@@ -102,10 +115,10 @@ array(2) {
| getMethod | param $query
return string | Get SQL Query method |
| getFields | param $query
return array | Get Query fields (at the moment only SELECTINSERTUPDATE) |
| getTable | param $query
return string | Get SQL Query First Table |
-| getTables | return array | Get SQL Query Tables |
+| getTables | return array | Get SQL Query Tables (including aliases) |
+| getTablesWithoutAliases | return array | Get SQL Query Tables (without aliases) |
| getJoinTables | return array | Get SQL Query Join Tables |
| hasJoin | return bool | Return if has join tables |
| getSubQueries | return array | Get all SELECT subqueries |
| hasSubQueries | return bool | Return if has subqueries |
-
diff --git a/src/LightSQLParser.php b/src/LightSQLParser.php
index fb2a929..5f00490 100644
--- a/src/LightSQLParser.php
+++ b/src/LightSQLParser.php
@@ -194,6 +194,22 @@ function getAllTables() {
return array_unique($results);
}
+ /**
+ * Get SQL Query Tables without aliases
+ * @return array
+ */
+ function getAllTablesWithoutAliases() {
+ $raw = $this->getAllTables();
+ $return = [];
+ foreach ($raw as $thistable) {
+ if (str_contains($thistable, " ")) {
+ $thistable = explode(" ", $thistable)[0];
+ }
+ $return[] = $thistable;
+ }
+ return $return;
+ }
+
/**
* Join tables.
* @return array