我有一个查询查找记录正常的查询。然后我需要回显所有以“Seq”开头并包含“1”的字段名称。
我的疑问:
SELECT * FROM ROSE_Hist
WHERE UniqueID = '1919' AND 1 IN ( SeqID0101,SeqID0102,SeqID0103 ,SeqID0104,SeqID0105,SeqID0106,SeqID0107,SeqID0108,SeqID0109,SeqID0110,SeqID0201,SeqID0202,SeqID0203,SeqID0301,SeqID0302,SeqID0303,SeqID0304,SeqID0401,SeqID0402,SeqID0403,SeqID0404,SeqID0501,
SeqID0502,SeqID0601,SeqID0602,SeqID0701,SeqID0702,SeqID0801,SeqID0802,SeqID0901,SeqID0902,SeqID0903,SeqID1001,SeqID1002,SeqID1003,SeqID1004,SeqID1101,SeqID1102,SeqID1201,SeqID1302,SeqID1303,SeqID1304,SeqID1305,
SeqID1401,SeqID1402,SeqID1403,SeqID1404,SeqID1405,SeqID1406,SeqID1407,SeqID1408,SeqID1409,SeqID1410,SeqID1411,SeqID1501,SeqID1502,SeqID1504,SeqID1505,SeqID1601,SeqID1602,SeqID1603,SeqID1604,SeqID1605,SeqID1701,SeqID1702,SeqID1703,SeqID1704,
SeqID1705,SeqID1801,SeqID1802,SeqID1901,SeqID1902,SeqID2001,SeqID2002,SeqID2101,SeqID2102,SeqID2201,SeqID2202,SeqID2203,SeqID2301,SeqID2302,SeqID2401,SeqID2402,SeqID2403,SeqID2501,SeqID2502,SeqID2503,SeqID2601,SeqID2602,SeqID2603,SeqID2701,
SeqID2702,SeqID2703,SeqID2704,SeqID2801,SeqID2901,SeqID2902,SeqID3001,SeqID3002,SeqID3101,SeqID3201,SeqID3202,SeqID3203,SeqID3204,SeqID3301,SeqID3302,SeqID3401,SeqID3402,SeqID3501,SeqID3502,SeqID3601,SeqID3602,SeqID3603,SeqID3604,SeqID3605,
SeqID3606,SeqID3701,SeqID3702,SeqID3703,SeqID3704,SeqID3801,SeqID3802,SeqID3803,SeqID3804,SeqID3901,SeqID3902,SeqID3903,SeqID3904,SeqID4001,SeqID4002,SeqID4003,SeqID4101,SeqID4102,SeqID4201,SeqID4202,SeqID4301,SeqID4302,SeqID4303,SeqID4304,
SeqID4401,SeqID4501,SeqID4502,SeqID4503,SeqID4504,SeqID4505,SeqID4506,SeqID4507,SeqID4508,SeqID4509,SeqID4510,SeqID4511,SeqID4512,SeqID4513,SeqID4514,SeqID4601,SeqID4602,SeqID4603,SeqID4604,SeqID4701,SeqID4702,SeqID4703,SeqID4704,SeqID4705) ORDER BY Room ASC
然后我需要循环遍历结果并且只搜索以“Seq”开头并包含数字“1”的字段。
foreach ($row_RoomAudit as $key => $val) {
print "$key = $val\n";
}
我在这里有些不对劲,因为“foreeach”正在呼应所有领域。为了回显以名称“Seq”开头的包含“1”的字段名称,我需要做些什么。
非常感谢你的时间。
答案 0 :(得分:0)
使用strpos快速解决问题,找到" 1"和substr找到' Seq'
roster.stream().map(Person::getSibling::getAge).collect(Collectors.toList());
答案 1 :(得分:0)
这是因为您使用*
选择所有字段。如果您只想选择这些特定列,则必须更改查询才能执行此操作:
SELECT SeqID0101,SeqID0102,SeqID0103 ,SeqID0104,SeqID0105,SeqID0106,SeqID0107,SeqID0108,SeqID0109,SeqID0110,SeqID0201,SeqID0202,SeqID0203,SeqID0301,SeqID0302,SeqID0303,SeqID0304,SeqID0401,SeqID0402,SeqID0403,SeqID0404,SeqID0501,
SeqID0502,SeqID0601,SeqID0602,SeqID0701,SeqID0702,SeqID0801,SeqID0802,SeqID0901,SeqID0902,SeqID0903,SeqID1001,SeqID1002,SeqID1003,SeqID1004,SeqID1101,SeqID1102,SeqID1201,SeqID1302,SeqID1303,SeqID1304,SeqID1305,
SeqID1401,SeqID1402,SeqID1403,SeqID1404,SeqID1405,SeqID1406,SeqID1407,SeqID1408,SeqID1409,SeqID1410,SeqID1411,SeqID1501,SeqID1502,SeqID1504,SeqID1505,SeqID1601,SeqID1602,SeqID1603,SeqID1604,SeqID1605,SeqID1701,SeqID1702,SeqID1703,SeqID1704,
SeqID1705,SeqID1801,SeqID1802,SeqID1901,SeqID1902,SeqID2001,SeqID2002,SeqID2101,SeqID2102,SeqID2201,SeqID2202,SeqID2203,SeqID2301,SeqID2302,SeqID2401,SeqID2402,SeqID2403,SeqID2501,SeqID2502,SeqID2503,SeqID2601,SeqID2602,SeqID2603,SeqID2701,
SeqID2702,SeqID2703,SeqID2704,SeqID2801,SeqID2901,SeqID2902,SeqID3001,SeqID3002,SeqID3101,SeqID3201,SeqID3202,SeqID3203,SeqID3204,SeqID3301,SeqID3302,SeqID3401,SeqID3402,SeqID3501,SeqID3502,SeqID3601,SeqID3602,SeqID3603,SeqID3604,SeqID3605,
SeqID3606,SeqID3701,SeqID3702,SeqID3703,SeqID3704,SeqID3801,SeqID3802,SeqID3803,SeqID3804,SeqID3901,SeqID3902,SeqID3903,SeqID3904,SeqID4001,SeqID4002,SeqID4003,SeqID4101,SeqID4102,SeqID4201,SeqID4202,SeqID4301,SeqID4302,SeqID4303,SeqID4304,
SeqID4401,SeqID4501,SeqID4502,SeqID4503,SeqID4504,SeqID4505,SeqID4506,SeqID4507,SeqID4508,SeqID4509,SeqID4510,SeqID4511,SeqID4512,SeqID4513,SeqID4514,SeqID4601,SeqID4602,SeqID4603,SeqID4604,SeqID4701,SeqID4702,SeqID4703,SeqID4704,SeqID4705 FROM ROSE_Hist
WHERE UniqueID = '1919' AND 1 IN ( SeqID0101,SeqID0102,SeqID0103 ,SeqID0104,SeqID0105,SeqID0106,SeqID0107,SeqID0108,SeqID0109,SeqID0110,SeqID0201,SeqID0202,SeqID0203,SeqID0301,SeqID0302,SeqID0303,SeqID0304,SeqID0401,SeqID0402,SeqID0403,SeqID0404,SeqID0501,
SeqID0502,SeqID0601,SeqID0602,SeqID0701,SeqID0702,SeqID0801,SeqID0802,SeqID0901,SeqID0902,SeqID0903,SeqID1001,SeqID1002,SeqID1003,SeqID1004,SeqID1101,SeqID1102,SeqID1201,SeqID1302,SeqID1303,SeqID1304,SeqID1305,
SeqID1401,SeqID1402,SeqID1403,SeqID1404,SeqID1405,SeqID1406,SeqID1407,SeqID1408,SeqID1409,SeqID1410,SeqID1411,SeqID1501,SeqID1502,SeqID1504,SeqID1505,SeqID1601,SeqID1602,SeqID1603,SeqID1604,SeqID1605,SeqID1701,SeqID1702,SeqID1703,SeqID1704,
SeqID1705,SeqID1801,SeqID1802,SeqID1901,SeqID1902,SeqID2001,SeqID2002,SeqID2101,SeqID2102,SeqID2201,SeqID2202,SeqID2203,SeqID2301,SeqID2302,SeqID2401,SeqID2402,SeqID2403,SeqID2501,SeqID2502,SeqID2503,SeqID2601,SeqID2602,SeqID2603,SeqID2701,
SeqID2702,SeqID2703,SeqID2704,SeqID2801,SeqID2901,SeqID2902,SeqID3001,SeqID3002,SeqID3101,SeqID3201,SeqID3202,SeqID3203,SeqID3204,SeqID3301,SeqID3302,SeqID3401,SeqID3402,SeqID3501,SeqID3502,SeqID3601,SeqID3602,SeqID3603,SeqID3604,SeqID3605,
SeqID3606,SeqID3701,SeqID3702,SeqID3703,SeqID3704,SeqID3801,SeqID3802,SeqID3803,SeqID3804,SeqID3901,SeqID3902,SeqID3903,SeqID3904,SeqID4001,SeqID4002,SeqID4003,SeqID4101,SeqID4102,SeqID4201,SeqID4202,SeqID4301,SeqID4302,SeqID4303,SeqID4304,
SeqID4401,SeqID4501,SeqID4502,SeqID4503,SeqID4504,SeqID4505,SeqID4506,SeqID4507,SeqID4508,SeqID4509,SeqID4510,SeqID4511,SeqID4512,SeqID4513,SeqID4514,SeqID4601,SeqID4602,SeqID4603,SeqID4604,SeqID4701,SeqID4702,SeqID4703,SeqID4704,SeqID4705) ORDER BY Room ASC
当然,循环内的过滤也是可能的,但更好的做法是仅请求您实际需要的数据。因此,如果您只需要输出这些列,则只应选择这些列。