在 sql 中使用&符号时如何传递和获取数据

how to pass and fetch data when using ampersand in sql

im trying to pass a url to fetch data for android JSON.

url是: fetch_cat_url = "xxx/get_product_details.php?task_name=get_cat&cat_name="+cat_name;

where cat_name="Books & More"
now when i pass this url.. it goes like

xxxxx/get_product_details.php?task_name=get_cat&cat_name=Books & More

in my sql file
switch($_GET["cat_name"])
        {
            case "Fashion":
            $sql = "SELECT * FROM `category` where c_name IN (\"Men\",\"Women\" ,\"Baby & Kids\") ";
            break;

            case "Home & Living":
            $sql = "SELECT * FROM `category` where c_name IN (\"Kitchenware\", \"Home Furnishing\", \"Home Decoratives\", \"Furniture\") ";
            break;

            case "Books & More":
            $sql = "SELECT * FROM `category` where c_name IN (\"Academic Text\", \"Literature & Fiction\", \"Non Fiction\", \"Self Help\", \"Children & Young Adult\", \"Competitive Exam\") ";
            break;

            case "Automotives":
            $sql = "SELECT * FROM `category` where c_name IN (\"Car Accessories\", \"Helmets & Accessories\", \"Car & Vehical Electronics\", \"Car Freshners\", \"Spare Parts\") ";
            break;
        }

now for & the data is not returned in json.. but it returns for rest all categories...

时尚和汽车的数据returns,但书籍和家居的数据

从客户端向 json 传递 cat_name 时,确保 json 字符串应该像这样编码。

String jsonString = Uri.EncodeDataString(json)

现在只需将 jsonString 传递给服务器.. 可能会有所帮助。