improved sql syntax