isthereanywaytoselectcolumnswithwildcards。
like
toselectcolumnswithnameshavingtypecouldbe ' select % type % from table _ name '?
not really.you can use the * columnwildcardtoselectallcolumns.if you ' rejoiningmultipletables,youcanselectalllcolumnsfromspecorecpectables
FROM articles AS a
JOIN blurbs AS b ON a.id=b.article
However,you shouldn ' tuse * unless you ' rewritingadbadministration program。
Alternatively,youcanbuildastatementwithinsqloranotherlanguagebyfetchingtablemetadatatogetthecolumnnames.usingjustmysql, youcanquerythecolumnstableintheinformation _ schemadatabasetogetthecolumnnamesandusegroup _ concattobuildthecolumnlistforthe
“选择”、
goup _ concat (column _ name separator ',')、
' FROM ',dbdb,'.',表,
' WHERE. '
)
FROM INFORMATION_SCHEMA.COLUMNS
where table _ schema=: dbandtable _ name=: table
Replace ':db ',' : table ' and ' . ' withtheappropriatevalues.youcaneventurnitintoapreparedstatemementsoyoucanucanuseite
if you ' renotlimitedtosqlforprogramming, itshouldbelessmessy.thedbdriverforyourlanguageofchoicelikelyoffersmethodstogetmetadata.theactualimplementationwouldbesimililata columnnames,assemble statement,prepare,execute ),but shouldn't be so ugly,asyou'dbeusinganalliang
iwouldbeveryinterestedinseeingthesituationthatthisisactuallyrequired .