---
title: "SQL  queries cleaner better in jquery"  
description: "SQL  queries cleaner better in jquery"  
author: "Manoj Bhatt"  
published: 2014-11-06  
updated: 2014-11-06  
canonical: https://www.mindstick.com/forum/2530/sql-queries-cleaner-better-in-jquery  
category: "mssql server"  
tags: ["mysql", "sql server", "sql"]  
reading_time: 1 minute  

---

# SQL  queries cleaner better in jquery

I have something like this:

```
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 4 LIMIT 1;
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 24 LIMIT 1;
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 29 LIMIT 1;
```

If will be more [queries](https://www.mindstick.com/forum/33678/sub-queries-in-sql-server) it will be very long. How do this in the other way, in [one line](https://www.mindstick.com/forum/159096/how-can-i-run-two-commands-in-one-line-in-windows-cmd)? But important is for me speed. cars.[brand](https://www.mindstick.com/articles/13090/icon-the-identity-of-your-brand) = X AND [LIMIT](https://www.mindstick.com/forum/159824/explain-the-purpose-of-the-limit-and-offset-clauses-and-how-are-they-used-for-pagination) X is a [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) so it maybe changes.

## Replies

### Reply by Anonymous User

You are worried about having to send so many queries one by one, so that would take a lot of time. You can make this one query instead:

```
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 4 LIMIT 1
UNION ALL
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 24 LIMIT 1
UNION ALL
SELECT cars.brand, cars.id FROM cars WHERE cars.brand = 29 LIMIT 1;
```


---

Original Source: https://www.mindstick.com/forum/2530/sql-queries-cleaner-better-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
